refactor: reorganize bootstrap

This commit is contained in:
winston 2023-11-26 12:12:22 +01:00
parent da65284a24
commit 1b033cae67
Signed by: winston
GPG key ID: 3786770EDBC2B481
3 changed files with 108 additions and 169 deletions

View file

@ -2,7 +2,9 @@
"nodes": { "nodes": {
"caarlos0-nur": { "caarlos0-nur": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": [
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1696990528, "lastModified": 1696990528,
@ -92,24 +94,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -154,7 +138,7 @@
"nekowinston-nur": { "nekowinston-nur": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
@ -217,16 +201,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1685677062, "lastModified": 1700204040,
"narHash": "sha256-zoHF7+HNwNwne2XEomphbdc4Y8tdWT16EUxUTXpOKpQ=", "narHash": "sha256-xSVcS5HBYnD3LTer7Y2K8ZQCDCXMa3QUD1MzRjHzuhI=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "95be94370d09f97f6af6a1df1eb9649b5260724e", "rev": "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixpkgs-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -249,39 +233,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 1700204040,
"narHash": "sha256-xSVcS5HBYnD3LTer7Y2K8ZQCDCXMa3QUD1MzRjHzuhI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1700612854, "lastModified": 1700612854,
"narHash": "sha256-yrQ8osMD+vDLGFX7pcwsY/Qr5PUd6OmDMYJZzZi0+zc=", "narHash": "sha256-yrQ8osMD+vDLGFX7pcwsY/Qr5PUd6OmDMYJZzZi0+zc=",
@ -297,22 +249,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_4": {
"locked": {
"lastModified": 1689261696,
"narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "df1eee2aa65052a18121ed4971081576b25d6b5c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1700844319, "lastModified": 1700844319,
@ -331,10 +267,16 @@
"pre-commit-hooks": { "pre-commit-hooks": {
"inputs": { "inputs": {
"flake-compat": [], "flake-compat": [],
"flake-utils": "flake-utils_3", "flake-utils": [
"flake-utils"
],
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": "nixpkgs_4", "nixpkgs": [
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs"
],
"nixpkgs-stable": [
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1700064067, "lastModified": 1700064067,
@ -360,7 +302,7 @@
"nekowinston-nur": "nekowinston-nur", "nekowinston-nur": "nekowinston-nur",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nix-vscode-extensions": "nix-vscode-extensions", "nix-vscode-extensions": "nix-vscode-extensions",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_2",
"nur": "nur", "nur": "nur",
"pre-commit-hooks": "pre-commit-hooks", "pre-commit-hooks": "pre-commit-hooks",
"sops": "sops", "sops": "sops",
@ -466,21 +408,6 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

109
flake.nix
View file

@ -1,48 +1,36 @@
{ {
description = "nekowinston's hm flake"; description = "nekowinston's hm flake";
inputs = { outputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts,
darwin.url = "github:lnl7/nix-darwin"; self,
darwin.inputs.nixpkgs.follows = "nixpkgs"; ...
home-manager.url = "github:nix-community/home-manager"; } @ inputs: let
home-manager.inputs.nixpkgs.follows = "nixpkgs"; inherit (import ./machines/lib.nix {inherit inputs overlays;}) mkSystems;
overlays = [
nur.url = "github:nix-community/nur"; (final: prev: {
caarlos0-nur.url = "github:caarlos0/nur"; nur = import inputs.nur {
nekowinston-nur.url = "github:nekowinston/nur"; nurpkgs = prev;
nix-vscode-extensions = { pkgs = prev;
url = "github:nix-community/nix-vscode-extensions"; repoOverrides = {
inputs.flake-compat.follows = ""; caarlos0 = inputs.caarlos0-nur.packages.${prev.system};
inputs.flake-utils.follows = "flake-utils"; nekowinston = inputs.nekowinston-nur.packages.${prev.system};
inputs.nixpkgs.follows = "nixpkgs"; };
}; };
nekowinston-nur = import inputs.nekowinston-nur {inherit (prev) pkgs;};
nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; sway-unwrapped = inputs.swayfx.packages.${prev.system}.default;
nix-index-database.url = "github:Mic92/nix-index-database"; })
sops.inputs.nixpkgs-stable.follows = "nixpkgs"; inputs.nix-vscode-extensions.overlays.default
sops.inputs.nixpkgs.follows = "nixpkgs"; ];
sops.url = "github:Mic92/sops-nix/1c673ba1053ad3e421fe043702237497bda0c621";
swayfx.inputs.flake-compat.follows = "";
swayfx.inputs.nixpkgs.follows = "nixpkgs";
swayfx.url = "github:willpower3309/swayfx";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.flake-compat.follows = "";
};
outputs = {flake-parts, ...} @ inputs: let
inherit (import ./machines/lib.nix {inherit inputs;}) mkSystems overlays;
in in
flake-parts.lib.mkFlake {inherit inputs;} flake-parts.lib.mkFlake {inherit self inputs;}
{ {
flake = mkSystems [ flake = mkSystems [
{ {
host = "sashimi"; host = "sashimi";
system = "aarch64-darwin"; system = "aarch64-darwin";
username = "winston"; username = "winston";
extraModules = [inputs.nekowinston-nur.darwinModules.default];
} }
{ {
host = "futomaki"; host = "futomaki";
@ -83,7 +71,7 @@
}; };
devShells.default = config.pre-commit.devShell.overrideAttrs (old: { devShells.default = config.pre-commit.devShell.overrideAttrs (old: {
buildInputs = with pkgs; [gum just nix-output-monitor nvd]; buildInputs = with pkgs; [alejandra gum just nil nix-output-monitor nvd];
}); });
legacyPackages.homeConfigurations = let legacyPackages.homeConfigurations = let
@ -120,4 +108,53 @@
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
]; ];
}; };
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/nur";
caarlos0-nur = {
url = "github:caarlos0/nur";
inputs.nixpkgs.follows = "nixpkgs";
};
nekowinston-nur.url = "github:nekowinston/nur";
nix-vscode-extensions = {
url = "github:nix-community/nix-vscode-extensions";
inputs.flake-compat.follows = "";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
nix-index-database.url = "github:Mic92/nix-index-database";
sops = {
url = "github:Mic92/sops-nix/1c673ba1053ad3e421fe043702237497bda0c621";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
swayfx = {
url = "github:willpower3309/swayfx";
inputs.flake-compat.follows = "";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-compat.follows = "";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
};
} }

View file

@ -1,19 +1,7 @@
{inputs}: rec { {
overlays = [ inputs,
(final: prev: { overlays,
nur = import inputs.nur { }: rec {
nurpkgs = prev;
pkgs = prev;
repoOverrides = {
caarlos0 = inputs.caarlos0-nur.packages.${prev.system};
nekowinston = inputs.nekowinston-nur.packages.${prev.system};
};
};
nekowinston-nur = import inputs.nekowinston-nur {inherit (prev) pkgs;};
sway-unwrapped = inputs.swayfx.packages.${prev.system}.default;
})
inputs.nix-vscode-extensions.overlays.default
];
hmCommonConfig = {username}: ({ hmCommonConfig = {username}: ({
config, config,
pkgs, pkgs,
@ -33,38 +21,25 @@
}; };
}; };
}); });
mkSystem = { mkSystem = {
host, host,
system, system,
username, username,
extraModules ? [], extraModules ? [],
}: let }: let
target = ldTernary = l: d:
if isLinux if pkgs.stdenv.isLinux
then "nixosConfigurations" then l
else if isDarwin else if pkgs.stdenv.isDarwin
then "darwinConfigurations" then d
else throw "Unsupported system";
builder = with inputs;
if isLinux
then nixpkgs.lib.nixosSystem
else if isDarwin
then darwin.lib.darwinSystem
else throw "Unsupported system";
module =
if isLinux
then "nixosModules"
else if isDarwin
then "darwinModules"
else throw "Unsupported system";
hostPlatform =
if isLinux
then "linux"
else if isDarwin
then "darwin"
else throw "Unsupported system"; else throw "Unsupported system";
target = ldTernary "nixosConfigurations" "darwinConfigurations";
builder = with inputs; ldTernary nixpkgs.lib.nixosSystem darwin.lib.darwinSystem;
module = ldTernary "nixosModules" "darwinModules";
hostPlatform = ldTernary "linux" "darwin";
pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs.stdenv) isDarwin isLinux;
in { in {
${target}."${host}" = builder { ${target}."${host}" = builder {
inherit system; inherit system;
@ -75,7 +50,7 @@
mkOption { mkOption {
description = "Main user of this configuration."; description = "Main user of this configuration.";
type = types.str; type = types.str;
default = "${username}"; default = username;
}; };
} }
./common/shared ./common/shared
@ -83,11 +58,11 @@
./${host} ./${host}
home-manager.${module}.home-manager home-manager.${module}.home-manager
] ]
++ pkgs.lib.optionals isDarwin [nekowinston-nur.darwinModules.default]
++ [(hmCommonConfig {inherit username;})] ++ [(hmCommonConfig {inherit username;})]
++ extraModules; ++ extraModules;
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
}; };
}; };
mkSystems = systems: inputs.nixpkgs.lib.mkMerge (map mkSystem systems); mkSystems = systems: inputs.nixpkgs.lib.mkMerge (map mkSystem systems);
} }