feat(flake): set up flake-parts

This commit is contained in:
Felix Schröter 2023-07-22 18:49:30 +02:00
parent 672f40ecd3
commit d91a8d24d4
Signed by: felschr
GPG key ID: 671E39E6744C807D
2 changed files with 220 additions and 194 deletions

View file

@ -100,6 +100,26 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1688466019,
"narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@ -293,6 +313,7 @@
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"deploy-rs": "deploy-rs", "deploy-rs": "deploy-rs",
"flake-parts": "flake-parts",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",

105
flake.nix
View file

@ -1,52 +1,61 @@
{ {
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-hardware.url = "github:NixOS/nixos-hardware/master";
inputs.flake-utils.url = "github:numtide/flake-utils"; flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
inputs.home-manager = { flake-utils.url = "github:numtide/flake-utils";
home-manager = {
url = "github:nix-community/home-manager/release-23.05"; url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
inputs.nur.url = "github:nix-community/NUR/master"; nur.url = "github:nix-community/NUR/master";
inputs.agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
inputs.deploy-rs = { deploy-rs = {
url = "github:serokell/deploy-rs"; url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils"; inputs.utils.follows = "flake-utils";
}; };
inputs.pre-commit-hooks = { pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix"; url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs"; inputs.nixpkgs-stable.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils"; inputs.flake-utils.follows = "flake-utils";
}; };
inputs.nvim-kitty-navigator = { nvim-kitty-navigator = {
url = "github:hermitmaster/nvim-kitty-navigator"; url = "github:hermitmaster/nvim-kitty-navigator";
flake = false; flake = false;
}; };
};
outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-utils outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-parts
, home-manager, nur, agenix, deploy-rs, pre-commit-hooks , flake-utils, home-manager, nur, agenix, deploy-rs, pre-commit-hooks
, nvim-kitty-navigator }@inputs: , nvim-kitty-navigator }@inputs:
let inputs.flake-parts.lib.mkFlake { inherit inputs; } {
nixpkgsConfig.allowUnfree = true; systems = [ "x86_64-linux" "aarch64-linux" ];
imports = [ ];
flake = rec {
overlays = { overlays = {
unstable = final: prev: { unstable = final: prev: {
unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
inherit (prev) system; inherit (prev) system;
config = nixpkgsConfig; config.allowUnfree = true;
}; };
}; };
neovim = final: prev: neovim = final: prev:
@ -68,22 +77,17 @@
deconz = final.qt5.callPackage ./pkgs/deconz { }; deconz = final.qt5.callPackage ./pkgs/deconz { };
}; };
wrappers = final: prev: { wrappers = final: prev: {
genericBinWrapper = final.callPackage ./pkgs/generic-bin-wrapper { }; genericBinWrapper =
final.callPackage ./pkgs/generic-bin-wrapper { };
mullvadExcludeWrapper = mullvadExcludeWrapper =
final.callPackage ./pkgs/mullvad-exclude-wrapper { }; final.callPackage ./pkgs/mullvad-exclude-wrapper { };
}; };
}; };
nixosModules = {
flakeDefaults = import ./modules/flakeDefaults.nix; lib = rec {
systemdNotify = import ./modules/systemdNotify.nix;
};
homeManagerModules = {
git = import ./home/modules/git.nix;
firefox = import ./home/modules/firefox/firefox.nix;
tor-browser = import ./home/modules/firefox/tor-browser.nix;
};
systemDefaults = { systemDefaults = {
modules = [ nixosModules.flakeDefaults agenix.nixosModules.default ]; modules =
[ nixosModules.flakeDefaults agenix.nixosModules.default ];
overlays = with overlays; [ overlays = with overlays; [
unstable unstable
nur.overlay nur.overlay
@ -92,7 +96,6 @@
wrappers wrappers
]; ];
}; };
lib = rec {
createSystem = hostName: createSystem = hostName:
{ hardwareConfig, config }: { hardwareConfig, config }:
({ pkgs, lib, ... }: { ({ pkgs, lib, ... }: {
@ -102,7 +105,7 @@
imports = systemDefaults.modules ++ [ hardwareConfig config ]; imports = systemDefaults.modules ++ [ hardwareConfig config ];
environment.systemPackages = with pkgs; environment.systemPackages =
[ agenix.packages.x86_64-linux.default ]; [ agenix.packages.x86_64-linux.default ];
}); });
createUser' = import ./lib/createUser.nix; createUser' = import ./lib/createUser.nix;
@ -111,12 +114,20 @@
(createUser' name args) ({ inherit home-manager; } // args2)); (createUser' name args) ({ inherit home-manager; } // args2));
createMediaGroup = _: { users.groups.media.gid = 600; }; createMediaGroup = _: { users.groups.media.gid = 600; };
}; };
specialArgs = { inherit inputs; };
in rec {
inherit lib overlays nixosModules homeManagerModules; nixosModules = {
flakeDefaults = import ./modules/flakeDefaults.nix;
systemdNotify = import ./modules/systemdNotify.nix;
};
nixosConfigurations.home-pc = nixpkgs.lib.nixosSystem { homeManagerModules = {
git = import ./home/modules/git.nix;
firefox = import ./home/modules/firefox/firefox.nix;
tor-browser = import ./home/modules/firefox/tor-browser.nix;
};
nixosConfigurations = {
home-pc = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
nixpkgs.nixosModules.notDetected nixpkgs.nixosModules.notDetected
@ -135,14 +146,13 @@
config = ./home/felschr.nix; config = ./home/felschr.nix;
}) })
({ pkgs, ... }: { ({ pkgs, ... }: {
environment.systemPackages = with pkgs; environment.systemPackages =
[ deploy-rs.defaultPackage.x86_64-linux ]; [ deploy-rs.defaultPackage.x86_64-linux ];
}) })
]; ];
inherit specialArgs; specialArgs = { inherit inputs; };
}; };
pilot1 = nixpkgs.lib.nixosSystem {
nixosConfigurations.pilot1 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
nixpkgs.nixosModules.notDetected nixpkgs.nixosModules.notDetected
@ -159,10 +169,9 @@
config = ./home/felschr-work.nix; config = ./home/felschr-work.nix;
}) })
]; ];
inherit specialArgs; specialArgs = { inherit inputs; };
}; };
home-server = nixpkgs.lib.nixosSystem {
nixosConfigurations.home-server = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
nixpkgs.nixosModules.notDetected nixpkgs.nixosModules.notDetected
@ -185,7 +194,8 @@
config = ./home/felschr-server.nix; config = ./home/felschr-server.nix;
}) })
]; ];
inherit specialArgs; specialArgs = { inherit inputs; };
};
}; };
deploy.nodes.home-server = { deploy.nodes.home-server = {
@ -196,16 +206,8 @@
self.nixosConfigurations.home-server; self.nixosConfigurations.home-server;
}; };
}; };
} // flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
config = nixpkgsConfig;
}; };
in rec { perSystem = { system, config, pkgs, ... }: rec {
formatter = pkgs.nixfmt;
packages = { deconz = pkgs.qt5.callPackage ./pkgs/deconz { }; }; packages = { deconz = pkgs.qt5.callPackage ./pkgs/deconz { }; };
apps = { deconz = flake-utils.lib.mkApp { drv = packages.deconz; }; }; apps = { deconz = flake-utils.lib.mkApp { drv = packages.deconz; }; };
@ -222,5 +224,8 @@
}; };
}; };
}; };
});
formatter = pkgs.nixfmt;
};
};
} }