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"
],
"utils": [
"flake-utils"
]
"utils": "utils"
},
"locked": {
"lastModified": 1718194053,
@ -138,6 +136,24 @@
"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": false,
"locked": {
@ -170,21 +186,21 @@
"type": "github"
}
},
"flake-utils": {
"flake-parts": {
"inputs": {
"systems": "systems"
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"lastModified": 1725234343,
"narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "567b938d64d4b4112ee253b9274472dc3a346eb6",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
@ -275,20 +291,32 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1725001927,
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=",
"lastModified": 1722073938,
"narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421",
"rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"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": {
"locked": {
"lastModified": 1721524707,
@ -305,6 +333,22 @@
"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": {
"locked": {
"lastModified": 1725103162,
@ -324,11 +368,12 @@
"root": {
"inputs": {
"deploy-rs": "deploy-rs",
"flake-utils": "flake-utils",
"devshell": "devshell",
"flake-parts": "flake-parts",
"home-manager": "home-manager",
"impermanence": "impermanence",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs_2",
"nixunstable": "nixunstable",
"sops-nix": "sops-nix",
"stylix": "stylix"
@ -402,6 +447,24 @@
"repo": "default",
"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",

203
flake.nix
View file

@ -3,10 +3,10 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
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 = {
url = "github:serokell/deploy-rs";
inputs.utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
@ -27,120 +27,101 @@
};
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
};
outputs = inputs@{ self, nixpkgs, flake-utils, home-manager, deploy-rs
, impermanence, stylix, nixos-hardware, nixunstable, ... }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
aarch64Pkgs = import nixpkgs { system = "aarch64-linux"; };
pkgs-unstable = import nixunstable { system = "x86_64-linux"; };
deployAarch64Pkgs = import nixpkgs {
system = "aarch64-linux";
overlays = [
deploy-rs.overlay
(self: super: {
deploy-rs = {
inherit (aarch64Pkgs) deploy-rs;
lib = super.deploy-rs.lib;
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ self, withSystem, ... }: {
imports = [ inputs.devshell.flakeModule ];
systems = [ "x86_64-linux" "aarch64-linux" ];
flake = {
# deploy = {
# sshUser = "root";
# fastConnection = true;
# nodes = withSystem "x86_64-linux" (ctx@{ deployPkgs, ... }: {
# 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;
# };
# }) // 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;
};
})
];
};
deployPkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
deploy-rs.overlay
(self: super: {
deploy-rs = {
inherit (pkgs) deploy-rs;
lib = super.deploy-rs.lib;
modules = [
./systems/smolboi/configuration.nix
inputs.stylix.nixosModules.stylix
inputs.impermanence.nixosModules.impermanence
inputs.nixos-hardware.nixosModules.common-cpu-amd
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
inputs.nixos-hardware.nixosModules.common-gpu-amd
inputs.nixos-hardware.nixosModules.common-pc
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.users.cdombroski =
import ./systems/smolboi/home.nix;
}
];
};
zeus = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
pkgs-unstable = inputs.nixunstable;
};
})
];
};
in {
nixosConfigurations = {
smolboi = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs;
inherit pkgs-unstable;
modules = [
./systems/zeus/configuration.nix
inputs.impermanence.nixosModules.impermanence
inputs.nixos-hardware.nixosModules.supermicro
inputs.nixos-hardware.nixosModules.common-cpu-amd
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
inputs.nixos-hardware.nixosModules.common-pc
];
};
modules = [
stylix.nixosModules.stylix
impermanence.nixosModules.impermanence
./systems/smolboi/configuration.nix
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-cpu-amd-zenpower
nixos-hardware.nixosModules.common-gpu-amd
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;
orangepihole = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
pkgs-unstable = inputs.nixunstable;
};
modules = [
./systems/orangepihole/configuration.nix
inputs.impermanence.nixosModules.impermanence
];
};
};
};
} // flake-utils.lib.eachDefaultSystem (system:
let
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;
perSystem = { pkgs, inputs', system, ... }: {
# _module.args.deployPkgs = import inputs'.nixpkgs {
# inherit system;
# overlays = [
# inputs.deploy-rs.overlay
# (final: prev: {
# deploy-rs = {
# 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;
});
};
});
}