flake-parts

This commit is contained in:
Chris Dombroski 2024-09-04 22:22:26 -04:00
parent 06dcd57463
commit 086139d84a
2 changed files with 173 additions and 129 deletions

View file

@ -120,9 +120,7 @@
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
"utils": [ "utils": "utils"
"flake-utils"
]
}, },
"locked": { "locked": {
"lastModified": 1718194053, "lastModified": 1718194053,
@ -138,6 +136,24 @@
"type": "github" "type": "github"
} }
}, },
"devshell": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1722113426,
"narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=",
"owner": "numtide",
"repo": "devshell",
"rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -170,21 +186,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-parts": {
"inputs": { "inputs": {
"systems": "systems" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1725234343,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=",
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"type": "github" "type": "github"
} }
}, },
@ -275,20 +291,32 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1725001927, "lastModified": 1722073938,
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=", "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421", "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-24.05", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"lastModified": 1725233747,
"narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
}
},
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1721524707, "lastModified": 1721524707,
@ -305,6 +333,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1725001927,
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixunstable": { "nixunstable": {
"locked": { "locked": {
"lastModified": 1725103162, "lastModified": 1725103162,
@ -324,11 +368,12 @@
"root": { "root": {
"inputs": { "inputs": {
"deploy-rs": "deploy-rs", "deploy-rs": "deploy-rs",
"flake-utils": "flake-utils", "devshell": "devshell",
"flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"impermanence": "impermanence", "impermanence": "impermanence",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs_2",
"nixunstable": "nixunstable", "nixunstable": "nixunstable",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
"stylix": "stylix" "stylix": "stylix"
@ -402,6 +447,24 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

203
flake.nix
View file

@ -3,10 +3,10 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixunstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixunstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
deploy-rs = { deploy-rs = {
url = "github:serokell/deploy-rs"; url = "github:serokell/deploy-rs";
inputs.utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
home-manager = { home-manager = {
@ -27,120 +27,101 @@
}; };
nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-hardware.url = "github:NixOS/nixos-hardware/master";
}; };
outputs = inputs@{ self, nixpkgs, flake-utils, home-manager, deploy-rs outputs = inputs@{ flake-parts, ... }:
, impermanence, stylix, nixos-hardware, nixunstable, ... }: flake-parts.lib.mkFlake { inherit inputs; } ({ self, withSystem, ... }: {
let imports = [ inputs.devshell.flakeModule ];
pkgs = import nixpkgs { system = "x86_64-linux"; }; systems = [ "x86_64-linux" "aarch64-linux" ];
aarch64Pkgs = import nixpkgs { system = "aarch64-linux"; }; flake = {
pkgs-unstable = import nixunstable { system = "x86_64-linux"; }; # deploy = {
deployAarch64Pkgs = import nixpkgs { # sshUser = "root";
system = "aarch64-linux"; # fastConnection = true;
overlays = [ # nodes = withSystem "x86_64-linux" (ctx@{ deployPkgs, ... }: {
deploy-rs.overlay # smolboi = {
(self: super: { # hostname = "smolboi";
deploy-rs = { # profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
inherit (aarch64Pkgs) deploy-rs; # self.nixosConfigurations.smolboi;
lib = super.deploy-rs.lib; # };
# zeus = {
# hostname = "zeus";
# profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
# self.nixosConfigurations.zeus;
# };
# }) // withSystem "aarch64-linux" (ctx@{ deployPkgs, ... }: {
# orangepihole = {
# hostname = "orangepihole";
# profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
# self.nixosConfigurations.orangepihole;
# };
# });
# };
nixosConfigurations = {
smolboi = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
pkgs-unstable = inputs.nixunstable;
}; };
}) modules = [
]; ./systems/smolboi/configuration.nix
}; inputs.stylix.nixosModules.stylix
deployPkgs = import nixpkgs { inputs.impermanence.nixosModules.impermanence
system = "x86_64-linux"; inputs.nixos-hardware.nixosModules.common-cpu-amd
overlays = [ inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
deploy-rs.overlay inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
(self: super: { inputs.nixos-hardware.nixosModules.common-gpu-amd
deploy-rs = { inputs.nixos-hardware.nixosModules.common-pc
inherit (pkgs) deploy-rs; inputs.nixos-hardware.nixosModules.common-pc-ssd
lib = super.deploy-rs.lib; inputs.nixos-hardware.nixosModules.gigabyte-b550
inputs.home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.users.cdombroski =
import ./systems/smolboi/home.nix;
}
];
};
zeus = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
pkgs-unstable = inputs.nixunstable;
}; };
}) modules = [
]; ./systems/zeus/configuration.nix
}; inputs.impermanence.nixosModules.impermanence
in { inputs.nixos-hardware.nixosModules.supermicro
nixosConfigurations = { inputs.nixos-hardware.nixosModules.common-cpu-amd
smolboi = nixpkgs.lib.nixosSystem { inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
system = "x86_64-linux"; inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
specialArgs = { inputs.nixos-hardware.nixosModules.common-pc
inherit inputs; ];
inherit pkgs-unstable;
}; };
modules = [ orangepihole = inputs.nixpkgs.lib.nixosSystem {
stylix.nixosModules.stylix specialArgs = {
impermanence.nixosModules.impermanence inherit inputs;
./systems/smolboi/configuration.nix pkgs-unstable = inputs.nixunstable;
nixos-hardware.nixosModules.common-cpu-amd };
nixos-hardware.nixosModules.common-cpu-amd-pstate modules = [
nixos-hardware.nixosModules.common-cpu-amd-zenpower ./systems/orangepihole/configuration.nix
nixos-hardware.nixosModules.common-gpu-amd inputs.impermanence.nixosModules.impermanence
nixos-hardware.nixosModules.common-pc ];
nixos-hardware.nixosModules.common-pc-ssd
nixos-hardware.nixosModules.gigabyte-b550
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.users.cdombroski = import ./systems/smolboi/home.nix;
}
];
};
zeus = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs;
inherit pkgs-unstable;
};
modules = [
impermanence.nixosModules.impermanence
./systems/zeus/configuration.nix
nixos-hardware.nixosModules.supermicro
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-cpu-amd-zenpower
nixos-hardware.nixosModules.common-pc
];
};
orangepihole = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = {
inherit inputs;
inherit pkgs-unstable;
};
modules = [
impermanence.nixosModules.impermanence
./systems/orangepihole/configuration.nix
];
};
};
deploy = {
sshUser = "root";
fastConnection = true;
nodes = {
smolboi = {
hostname = "smolboi";
profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
self.nixosConfigurations.smolboi;
};
zeus = {
hostname = "zeus";
profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
self.nixosConfigurations.zeus;
};
orangepihole = {
hostname = "orangepihole";
profiles.system.path =
deployAarch64Pkgs.deploy-rs.lib.activate.nixos
self.nixosConfigurations.orangepihole;
}; };
}; };
}; };
} // flake-utils.lib.eachDefaultSystem (system: perSystem = { pkgs, inputs', system, ... }: {
let # _module.args.deployPkgs = import inputs'.nixpkgs {
pkgs = nixpkgs.legacyPackages.${system}; # inherit system;
deployLib = deploy-rs.lib.${system}; # overlays = [
in { # inputs.deploy-rs.overlay
devShells.default = # (final: prev: {
pkgs.mkShell { buildInputs = [ pkgs.deploy-rs pkgs.sops ]; }; # deploy-rs = {
checks = deployLib.deployChecks self.deploy; # inherit (pkgs) deploy-rs;
# lib = prev.deploy-rs.lib;
# };
# })
# ];
# };
devshells.default = { packages = [ pkgs.deploy-rs pkgs.sops ]; };
# checks = inputs.deploy-rs.lib.${system}.deployChecks self.deploy;
formatter = pkgs.nixfmt; formatter = pkgs.nixfmt;
}); };
});
} }