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",

159
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;
deployPkgs = import nixpkgs { # };
system = "x86_64-linux"; # }) // withSystem "aarch64-linux" (ctx@{ deployPkgs, ... }: {
overlays = [ # orangepihole = {
deploy-rs.overlay # hostname = "orangepihole";
(self: super: { # profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
deploy-rs = { # self.nixosConfigurations.orangepihole;
inherit (pkgs) deploy-rs; # };
lib = super.deploy-rs.lib; # });
}; # };
})
];
};
in {
nixosConfigurations = { nixosConfigurations = {
smolboi = nixpkgs.lib.nixosSystem { smolboi = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
inherit pkgs-unstable; pkgs-unstable = inputs.nixunstable;
}; };
modules = [ modules = [
stylix.nixosModules.stylix
impermanence.nixosModules.impermanence
./systems/smolboi/configuration.nix ./systems/smolboi/configuration.nix
nixos-hardware.nixosModules.common-cpu-amd inputs.stylix.nixosModules.stylix
nixos-hardware.nixosModules.common-cpu-amd-pstate inputs.impermanence.nixosModules.impermanence
nixos-hardware.nixosModules.common-cpu-amd-zenpower inputs.nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-gpu-amd inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-pc inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
nixos-hardware.nixosModules.common-pc-ssd inputs.nixos-hardware.nixosModules.common-gpu-amd
nixos-hardware.nixosModules.gigabyte-b550 inputs.nixos-hardware.nixosModules.common-pc
home-manager.nixosModules.home-manager inputs.nixos-hardware.nixosModules.common-pc-ssd
inputs.nixos-hardware.nixosModules.gigabyte-b550
inputs.home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.users.cdombroski = import ./systems/smolboi/home.nix; home-manager.users.cdombroski =
import ./systems/smolboi/home.nix;
} }
]; ];
}; };
zeus = nixpkgs.lib.nixosSystem { zeus = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
inherit pkgs-unstable; pkgs-unstable = inputs.nixunstable;
}; };
modules = [ modules = [
impermanence.nixosModules.impermanence
./systems/zeus/configuration.nix ./systems/zeus/configuration.nix
nixos-hardware.nixosModules.supermicro inputs.impermanence.nixosModules.impermanence
nixos-hardware.nixosModules.common-cpu-amd inputs.nixos-hardware.nixosModules.supermicro
nixos-hardware.nixosModules.common-cpu-amd-pstate inputs.nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-cpu-amd-zenpower inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-pc inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
inputs.nixos-hardware.nixosModules.common-pc
]; ];
}; };
orangepihole = nixpkgs.lib.nixosSystem { orangepihole = inputs.nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
inherit pkgs-unstable; pkgs-unstable = inputs.nixunstable;
}; };
modules = [ modules = [
impermanence.nixosModules.impermanence
./systems/orangepihole/configuration.nix ./systems/orangepihole/configuration.nix
inputs.impermanence.nixosModules.impermanence
]; ];
}; };
}; };
deploy = {
sshUser = "root";
fastConnection = true;
nodes = {
smolboi = {
hostname = "smolboi";
profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos
self.nixosConfigurations.smolboi;
}; };
zeus = { perSystem = { pkgs, inputs', system, ... }: {
hostname = "zeus"; # _module.args.deployPkgs = import inputs'.nixpkgs {
profiles.system.path = deployPkgs.deploy-rs.lib.activate.nixos # inherit system;
self.nixosConfigurations.zeus; # overlays = [
}; # inputs.deploy-rs.overlay
orangepihole = { # (final: prev: {
hostname = "orangepihole"; # deploy-rs = {
profiles.system.path = # inherit (pkgs) deploy-rs;
deployAarch64Pkgs.deploy-rs.lib.activate.nixos # lib = prev.deploy-rs.lib;
self.nixosConfigurations.orangepihole; # };
}; # })
}; # ];
}; # };
} // flake-utils.lib.eachDefaultSystem (system: devshells.default = { packages = [ pkgs.deploy-rs pkgs.sops ]; };
let # checks = inputs.deploy-rs.lib.${system}.deployChecks self.deploy;
pkgs = nixpkgs.legacyPackages.${system};
deployLib = deploy-rs.lib.${system};
in {
devShells.default =
pkgs.mkShell { buildInputs = [ pkgs.deploy-rs pkgs.sops ]; };
checks = deployLib.deployChecks self.deploy;
formatter = pkgs.nixfmt; formatter = pkgs.nixfmt;
};
}); });
} }