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": {
"caarlos0-nur": {
"inputs": {
"nixpkgs": "nixpkgs"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1696990528,
@ -92,24 +94,6 @@
"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": {
"inputs": {
"nixpkgs": [
@ -154,7 +138,7 @@
"nekowinston-nur": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
},
"locked": {
@ -217,16 +201,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1685677062,
"narHash": "sha256-zoHF7+HNwNwne2XEomphbdc4Y8tdWT16EUxUTXpOKpQ=",
"lastModified": 1700204040,
"narHash": "sha256-xSVcS5HBYnD3LTer7Y2K8ZQCDCXMa3QUD1MzRjHzuhI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "95be94370d09f97f6af6a1df1eb9649b5260724e",
"rev": "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
@ -249,39 +233,7 @@
"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": {
"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": {
"lastModified": 1700612854,
"narHash": "sha256-yrQ8osMD+vDLGFX7pcwsY/Qr5PUd6OmDMYJZzZi0+zc=",
@ -297,22 +249,6 @@
"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": {
"locked": {
"lastModified": 1700844319,
@ -331,10 +267,16 @@
"pre-commit-hooks": {
"inputs": {
"flake-compat": [],
"flake-utils": "flake-utils_3",
"flake-utils": [
"flake-utils"
],
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_4",
"nixpkgs-stable": "nixpkgs-stable"
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1700064067,
@ -360,7 +302,7 @@
"nekowinston-nur": "nekowinston-nur",
"nix-index-database": "nix-index-database",
"nix-vscode-extensions": "nix-vscode-extensions",
"nixpkgs": "nixpkgs_3",
"nixpkgs": "nixpkgs_2",
"nur": "nur",
"pre-commit-hooks": "pre-commit-hooks",
"sops": "sops",
@ -466,21 +408,6 @@
"repo": "default",
"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",

109
flake.nix
View file

@ -1,48 +1,36 @@
{
description = "nekowinston's hm flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nur.url = "github:nix-community/nur";
caarlos0-nur.url = "github:caarlos0/nur";
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.inputs.nixpkgs-stable.follows = "nixpkgs";
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;
outputs = {
flake-parts,
self,
...
} @ inputs: let
inherit (import ./machines/lib.nix {inherit inputs overlays;}) mkSystems;
overlays = [
(final: prev: {
nur = import inputs.nur {
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
];
in
flake-parts.lib.mkFlake {inherit inputs;}
flake-parts.lib.mkFlake {inherit self inputs;}
{
flake = mkSystems [
{
host = "sashimi";
system = "aarch64-darwin";
username = "winston";
extraModules = [inputs.nekowinston-nur.darwinModules.default];
}
{
host = "futomaki";
@ -83,7 +71,7 @@
};
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
@ -120,4 +108,53 @@
"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 = [
(final: prev: {
nur = import inputs.nur {
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
];
{
inputs,
overlays,
}: rec {
hmCommonConfig = {username}: ({
config,
pkgs,
@ -33,38 +21,25 @@
};
};
});
mkSystem = {
host,
system,
username,
extraModules ? [],
}: let
target =
if isLinux
then "nixosConfigurations"
else if isDarwin
then "darwinConfigurations"
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"
ldTernary = l: d:
if pkgs.stdenv.isLinux
then l
else if pkgs.stdenv.isDarwin
then d
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};
inherit (pkgs.stdenv) isDarwin isLinux;
in {
${target}."${host}" = builder {
inherit system;
@ -75,7 +50,7 @@
mkOption {
description = "Main user of this configuration.";
type = types.str;
default = "${username}";
default = username;
};
}
./common/shared
@ -83,11 +58,11 @@
./${host}
home-manager.${module}.home-manager
]
++ pkgs.lib.optionals isDarwin [nekowinston-nur.darwinModules.default]
++ [(hmCommonConfig {inherit username;})]
++ extraModules;
specialArgs = {inherit inputs;};
};
};
mkSystems = systems: inputs.nixpkgs.lib.mkMerge (map mkSystem systems);
}