config/flake.nix

249 lines
5.8 KiB
Nix

2023-01-13 20:12:54 +01:00
{
inputs = {
2023-06-26 14:42:29 +02:00
nixpkgs.url = "nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable";
2023-05-07 03:59:51 +02:00
nur.url = "github:nix-community/nur";
sanctureplicum-nur = {
2023-06-16 07:37:30 +02:00
url = "git+https://gitea.pid1.sh/sanctureplicum/nur";
2023-06-26 14:42:29 +02:00
inputs.nixpkgs.follows = "nixpkgs-unstable";
2023-05-07 03:59:51 +02:00
};
nekowinston-nur = {
url = "github:nekowinston/nur";
2023-06-26 14:42:29 +02:00
inputs.nixpkgs.follows = "nixpkgs-unstable";
2023-05-07 03:59:51 +02:00
};
home-manager = {
2023-06-16 06:42:12 +02:00
url = "github:nix-community/home-manager/release-23.05";
2023-05-07 03:59:51 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs = {
2023-06-26 14:42:29 +02:00
nixpkgs.follows = "nixpkgs-unstable";
2023-05-07 03:59:51 +02:00
nixpkgs-stable.follows = "nixpkgs";
};
};
nixos-wsl = {
url = "github:nix-community/nixos-wsl";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-06-16 06:42:12 +02:00
nix-darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-06-04 23:05:10 +02:00
crane = {
url = "github:ipetkov/crane/v0.11.3";
2023-06-16 10:38:12 +02:00
inputs.nixpkgs.follows = "nixpkgs";
2023-06-04 23:05:10 +02:00
};
2023-05-07 03:59:51 +02:00
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
2023-06-26 14:42:29 +02:00
inputs.nixpkgs.follows = "nixpkgs-unstable";
2023-05-07 03:59:51 +02:00
};
2023-01-13 20:12:54 +01:00
};
2023-06-03 11:42:15 +02:00
outputs = {
self,
nixpkgs,
2023-06-26 14:42:29 +02:00
nixpkgs-unstable,
2023-06-03 11:42:15 +02:00
nur,
sanctureplicum-nur,
nekowinston-nur,
emacs-overlay,
nixos-wsl,
2023-06-16 06:42:12 +02:00
nix-darwin,
2023-06-03 11:42:15 +02:00
sops-nix,
2023-06-04 23:05:10 +02:00
crane,
2023-06-03 11:42:15 +02:00
home-manager,
...
} @ inputs: let
overlays = [
(import emacs-overlay)
2023-06-26 14:42:29 +02:00
(final: prev: let
unstable = import nixpkgs-unstable {
system = prev.system;
config.allowUnfree = true;
};
in {
2023-06-03 11:42:15 +02:00
nur = import nur {
2023-06-16 10:38:12 +02:00
nurpkgs = prev;
pkgs = prev;
2023-06-03 11:42:15 +02:00
repoOverrides = {
2023-06-16 10:38:12 +02:00
nekowinston = import nekowinston-nur {pkgs = prev;};
2023-06-03 11:42:15 +02:00
sanctureplicum = import sanctureplicum-nur {
2023-06-16 10:38:12 +02:00
pkgs = prev;
system = prev.system;
2023-04-12 13:45:45 +02:00
};
};
2023-06-03 11:42:15 +02:00
};
2023-06-26 14:42:29 +02:00
inherit unstable;
2023-06-03 11:42:15 +02:00
})
];
2023-06-26 14:42:29 +02:00
overlayModule = {
config,
pkgs,
...
}: {
nixpkgs.overlays = overlays;
};
hmConfig = sops: [
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "bak";
home-manager.sharedModules =
if sops
then [
sops-nix.homeManagerModule
]
else [];
home-manager.extraSpecialArgs = {inherit inputs;};
}
./users/carsten
];
mkSystem = {
host,
system,
hm ? true,
wsl ? false,
sops ? false,
sops-hm ? false,
modules ? [],
}: let
isDarwin = builtins.match ".+?-linux" == null;
builder =
if isDarwin
then nix-darwin.lib.darwinSystem
else nixpkgs.lib.nixosSystem;
hmModule =
if isDarwin
then home-manager.darwinModules.home-manager
else home-manager.nixosModules.home-manager;
sopsModule =
if isDarwin
then sops-nix.darwinModules.sops
else sops-nix.nixosModules.sops;
systemModule =
if isDarwin
then ./hosts/common/darwin.nix
else ./hosts/common/linux.nix;
in
builder {
inherit system;
specialArgs = {
inherit inputs;
};
modules =
[
overlayModule
(./hosts + "/${host}")
systemModule
]
++ (
if hm
then [hmModule] ++ (hmConfig sops-hm)
else []
)
++ (
if wsl
then [nixos-wsl.nixosModules.wsl]
else []
)
++ (
if sops
then [sopsModule]
else []
)
++ modules;
};
2023-06-03 11:42:15 +02:00
in {
nixosConfigurations.falcon = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
2023-06-26 14:42:29 +02:00
specialArgs = {
inherit inputs;
};
modules =
[
overlayModule
2023-06-03 11:42:15 +02:00
2023-06-26 14:42:29 +02:00
home-manager.nixosModules.home-manager
./hosts/falcon
./hosts/common/linux.nix
]
++ hmConfig;
2023-06-03 11:42:15 +02:00
};
nixosConfigurations.eagle = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
2023-06-26 14:42:29 +02:00
specialArgs = {
inherit inputs;
};
modules =
[
overlayModule
2023-01-13 20:12:54 +01:00
2023-06-26 14:42:29 +02:00
home-manager.nixosModules.home-manager
{
home-manager.sharedModules = [
sops-nix.homeManagerModule
];
}
./hosts/eagle
./hosts/common/linux.nix
]
++ hmConfig;
2023-06-16 06:42:12 +02:00
};
darwinConfigurations.hawk = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
2023-06-26 14:42:29 +02:00
specialArgs = {
inherit inputs;
};
modules =
[
overlayModule
home-manager.darwinModules.home-manager
{
home-manager.sharedModules = [
sops-nix.homeManagerModule
];
}
./hosts/hawk
./hosts/common/darwin.nix
]
++ hmConfig;
2023-06-03 11:42:15 +02:00
};
2023-01-16 14:49:16 +01:00
2023-06-26 14:42:29 +02:00
nixosConfigurations.buzzard = mkSystem {
host = "buzzard";
system = "x86_64-linux";
wsl = true;
2023-06-03 11:42:15 +02:00
};
2023-06-26 14:42:29 +02:00
# nixpkgs.lib.nixosSystem {
# system = "x86_64-linux";
# specialArgs = {
# inherit inputs;
# };
# modules =
# [
# overlayModule
# nixos-wsl.nixosModules.wsl
# home-manager.nixosModules.home-manager
# ./hosts/buzzard
# ./hosts/common/linux.nix
# ]
# ++ hmConfig;
# };
2023-06-03 11:42:15 +02:00
nixosConfigurations.gitea = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
2023-06-26 14:42:29 +02:00
specialArgs = {
inherit inputs;
craneLib = crane.lib."x86_64-linux";
};
2023-06-03 11:42:15 +02:00
modules = [
2023-06-26 14:42:29 +02:00
overlayModule
2023-06-03 11:42:15 +02:00
sops-nix.nixosModules.sops
./hosts/gitea
2023-06-16 06:42:12 +02:00
./hosts/common/linux.nix
2023-06-03 11:42:15 +02:00
];
2023-01-13 20:12:54 +01:00
};
2023-06-03 11:42:15 +02:00
};
2023-01-13 20:12:54 +01:00
}