mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
feat: overlays + pkgs
This commit is contained in:
parent
bed84b16b0
commit
5da80d3c52
17 changed files with 210 additions and 91 deletions
1
.envrc
1
.envrc
|
|
@ -1,2 +1,3 @@
|
||||||
export REPO_ROOT="$(pwd)"
|
export REPO_ROOT="$(pwd)"
|
||||||
|
export REPO_HOSTNAME=$(hostname -s)
|
||||||
use flake
|
use flake
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ venv/
|
||||||
.direnv/
|
.direnv/
|
||||||
result
|
result
|
||||||
/kittywitch
|
/kittywitch
|
||||||
|
data/
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,17 @@
|
||||||
lib,
|
lib,
|
||||||
std,
|
std,
|
||||||
inputs,
|
inputs,
|
||||||
tree,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (std) set tuple list;
|
inherit (std) set tuple list;
|
||||||
inherit (lib.strings) versionAtLeast;
|
inherit (lib.strings) versionAtLeast;
|
||||||
renameAttrs = names: set.remap ({_0, _1}: tuple.tuple2 (names.${_0} or _0) _1);
|
renameAttrs = names:
|
||||||
renameAttr = oldName: newName: renameAttrs { ${oldName} = newName; };
|
set.remap ({
|
||||||
|
_0,
|
||||||
|
_1,
|
||||||
|
}:
|
||||||
|
tuple.tuple2 (names.${_0} or _0) _1);
|
||||||
|
renameAttr = oldName: newName: renameAttrs {${oldName} = newName;};
|
||||||
in {
|
in {
|
||||||
nix = {
|
nix = {
|
||||||
nixPath = set.mapToValues (name: flake: "${name}=${flake.outPath}") (renameAttr "self" "kat" inputs);
|
nixPath = set.mapToValues (name: flake: "${name}=${flake.outPath}") (renameAttr "self" "kat" inputs);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
{inputs, ...}: {
|
{
|
||||||
|
inputs,
|
||||||
|
tree,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
nixpkgs = {
|
nixpkgs = {
|
||||||
overlays = map (path: import "${path}/overlay.nix") [
|
overlays = import tree.overlays {inherit inputs;};
|
||||||
inputs.arcexprs
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
flake.lock
generated
48
flake.lock
generated
|
|
@ -59,6 +59,32 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deploy-rs": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"flake-compat"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"utils": [
|
||||||
|
"utils"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1674127017,
|
||||||
|
"narHash": "sha256-QO1xF7stu5ZMDLbHN30LFolMAwY6TVlzYvQoUs1RD68=",
|
||||||
|
"owner": "serokell",
|
||||||
|
"repo": "deploy-rs",
|
||||||
|
"rev": "8c9ea9605eed20528bf60fae35a2b613b901fd77",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "serokell",
|
||||||
|
"repo": "deploy-rs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"empty": {
|
"empty": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1630400035,
|
"lastModified": 1630400035,
|
||||||
|
|
@ -95,7 +121,9 @@
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"utils": "utils"
|
"utils": [
|
||||||
|
"utils"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1674041176,
|
"lastModified": 1674041176,
|
||||||
|
|
@ -219,6 +247,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"arcexprs": "arcexprs",
|
"arcexprs": "arcexprs",
|
||||||
"darwin": "darwin",
|
"darwin": "darwin",
|
||||||
|
"deploy-rs": "deploy-rs",
|
||||||
"empty": "empty",
|
"empty": "empty",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
|
|
@ -230,7 +259,7 @@
|
||||||
"scalpel": "scalpel",
|
"scalpel": "scalpel",
|
||||||
"std": "std",
|
"std": "std",
|
||||||
"tree": "tree",
|
"tree": "tree",
|
||||||
"utils": "utils_2"
|
"utils": "utils"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
|
|
@ -333,21 +362,6 @@
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"utils_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1667395993,
|
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
16
flake.nix
16
flake.nix
|
|
@ -14,10 +14,22 @@
|
||||||
empty.url = "github:input-output-hk/empty-flake";
|
empty.url = "github:input-output-hk/empty-flake";
|
||||||
# self-explanatory
|
# self-explanatory
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
# deployments
|
||||||
|
deploy-rs = {
|
||||||
|
url = "github:serokell/deploy-rs";
|
||||||
|
inputs = {
|
||||||
|
flake-compat.follows = "flake-compat";
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
utils.follows = "utils";
|
||||||
|
};
|
||||||
|
};
|
||||||
# self-explanatory
|
# self-explanatory
|
||||||
home-manager = {
|
home-manager = {
|
||||||
url = "github:nix-community/home-manager/master";
|
url = "github:nix-community/home-manager/master";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
utils.follows = "utils";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
# self-explanatory
|
# self-explanatory
|
||||||
darwin = {
|
darwin = {
|
||||||
|
|
@ -76,5 +88,5 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = inputs: import ./outputs.nix { inherit inputs; };
|
outputs = inputs: import ./outputs.nix {inherit inputs;};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
formatter.nix
Normal file
8
formatter.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
inputs.utils.lib.eachDefaultSystem (system: {
|
||||||
|
${system} = pkgs.${system}.alejandra;
|
||||||
|
})
|
||||||
3
nixos/common/nix-index.nix
Normal file
3
nixos/common/nix-index.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
_: {
|
||||||
|
programs.command-not-found.enable = false;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.modules) mkDefault;
|
inherit (lib.modules) mkDefault;
|
||||||
in {
|
in {
|
||||||
|
boot.loader = {
|
||||||
|
grub.configurationLimit = 8;
|
||||||
|
systemd-boot.configurationLimit = 8;
|
||||||
|
};
|
||||||
|
|
||||||
nix.gc = {
|
nix.gc = {
|
||||||
automatic = mkDefault true;
|
automatic = mkDefault true;
|
||||||
dates = mkDefault "weekly";
|
dates = mkDefault "weekly";
|
||||||
10
outputs.nix
10
outputs.nix
|
|
@ -1,8 +1,12 @@
|
||||||
{ inputs }: let
|
{inputs}: let
|
||||||
inherit (inputs.nixpkgs) lib;
|
inherit (inputs.nixpkgs) lib;
|
||||||
std = import ./std.nix {inherit inputs;};
|
std = import ./std.nix {inherit inputs;};
|
||||||
tree = import ./tree.nix {inherit inputs;};
|
tree = import ./tree.nix {inherit inputs;};
|
||||||
systems = import ./systems {inherit inputs tree lib std;};
|
systems = import ./systems {inherit inputs tree lib std;};
|
||||||
shells = import ./shells {inherit inputs tree lib std;};
|
shells = import ./shells {inherit inputs tree lib std pkgs;};
|
||||||
|
inherit (import ./pkgs.nix {inherit inputs tree lib;}) pkgs;
|
||||||
|
formatter = import ./formatter.nix {inherit inputs pkgs;};
|
||||||
|
inherit (std) set;
|
||||||
|
checks = set.map (_: deployLib: deployLib.deployChecks inputs.self.deploy) inputs.deploy-rs.lib;
|
||||||
in
|
in
|
||||||
{inherit inputs tree lib std;} // systems // shells
|
{inherit inputs tree lib std pkgs checks formatter;} // systems // shells
|
||||||
|
|
|
||||||
7
overlays.nix
Normal file
7
overlays.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{inputs, ...}:
|
||||||
|
[
|
||||||
|
inputs.deploy-rs.overlay
|
||||||
|
]
|
||||||
|
++ map (path: import "${path}/overlay.nix") [
|
||||||
|
inputs.arcexprs
|
||||||
|
]
|
||||||
9
pkgs.nix
Normal file
9
pkgs.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
tree,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
overlays = import tree.overlays {inherit inputs;};
|
||||||
|
in
|
||||||
|
inputs.utils.lib.eachDefaultSystem (system: {pkgs = import inputs.nixpkgs {inherit system overlays;};})
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
tree,
|
tree,
|
||||||
inputs,
|
inputs,
|
||||||
std,
|
std,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (std) set;
|
inherit (std) set;
|
||||||
|
|
@ -10,9 +11,9 @@ in
|
||||||
inputs.utils.lib.eachDefaultSystem (system: {
|
inputs.utils.lib.eachDefaultSystem (system: {
|
||||||
devShells = let
|
devShells = let
|
||||||
shells = set.map (_: path:
|
shells = set.map (_: path:
|
||||||
import path rec {
|
import path {
|
||||||
inherit tree inputs system lib std;
|
inherit tree inputs system lib std;
|
||||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
pkgs = pkgs.${system};
|
||||||
})
|
})
|
||||||
tree.shells;
|
tree.shells;
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,33 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with pkgs; let
|
with pkgs; let
|
||||||
repo = import ../outputs.nix { inherit inputs; };
|
repo = import ../outputs.nix {inherit inputs;};
|
||||||
inherit (std) set list;
|
inherit (std) set;
|
||||||
repoShell = mkShell {
|
repoShell = mkShell {
|
||||||
nativeBuildInputs =
|
nativeBuildInputs =
|
||||||
[
|
[
|
||||||
|
fd # fd, better fine!
|
||||||
|
ripgrep # rg, better grep!
|
||||||
go # Required for pulumi
|
go # Required for pulumi
|
||||||
pulumi-bin # Infrastructure as code
|
pulumi-bin # Infrastructure as code
|
||||||
deadnix # dead-code scanner
|
deadnix # dead-code scanner
|
||||||
alejandra # code formatter
|
alejandra # code formatter
|
||||||
statix # anti-pattern finder
|
statix # anti-pattern finder
|
||||||
|
deploy-rs.deploy-rs # deployment system
|
||||||
]
|
]
|
||||||
++ set.values (set.map (name: _: (pkgs.writeShellScriptBin "${name}-rebuild" ''
|
++ set.values (set.map (name: _: (pkgs.writeShellScriptBin "${name}-rebuild" ''
|
||||||
darwin-rebuild switch --flake $REPO_ROOT#${name}
|
darwin-rebuild switch --flake $REPO_ROOT#${name}
|
||||||
''))
|
''))
|
||||||
repo.darwinConfigurations);
|
repo.darwinConfigurations);
|
||||||
|
shellHook = ''
|
||||||
|
echo -e "\e[39m\e[1m$USER@$REPO_HOSTNAME - \e[35m''$(realpath --relative-to=../ ./nixos/)\e[0m"
|
||||||
|
echo -e "\e[35mRunning alejandra\e[0m"
|
||||||
|
alejandra -cq $(fd -e nix)
|
||||||
|
echo -e "\e[35mRunning statix\e[0m"
|
||||||
|
statix check
|
||||||
|
echo -e "\e[35mRunning deadnix\e[0m"
|
||||||
|
deadnix
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
in repoShell
|
in
|
||||||
|
repoShell
|
||||||
|
|
|
||||||
120
std.nix
120
std.nix
|
|
@ -1,63 +1,77 @@
|
||||||
{ inputs, ... }: let
|
{inputs, ...}: let
|
||||||
std = let
|
std = let
|
||||||
baseStd = inputs.std.lib;
|
baseStd = inputs.std.lib;
|
||||||
inherit (baseStd) set function list bool types optional;
|
inherit (baseStd) set function list bool types optional;
|
||||||
mergeWith = let
|
mergeWith = let
|
||||||
append = {
|
append = {
|
||||||
path
|
path,
|
||||||
, values
|
values,
|
||||||
, canMerge
|
canMerge,
|
||||||
, mapToSet
|
mapToSet,
|
||||||
}: let
|
}: let
|
||||||
mergeWith' = values: mergeWith {
|
mergeWith' = values:
|
||||||
inherit canMerge mapToSet path;
|
mergeWith {
|
||||||
sets = list.map (v: (mapToSet path v).value) values;
|
inherit canMerge mapToSet path;
|
||||||
};
|
sets = list.map (v: (mapToSet path v).value) values;
|
||||||
|
};
|
||||||
mergeUntil = list.findIndex (function.not (canMerge path)) values;
|
mergeUntil = list.findIndex (function.not (canMerge path)) values;
|
||||||
len = list.length values;
|
len = list.length values;
|
||||||
in if len == 0 then { }
|
in
|
||||||
else if len == 1 then list.unsafeHead values
|
if len == 0
|
||||||
else if list.all (canMerge path) values then mergeWith' values
|
then {}
|
||||||
else optional.match mergeUntil {
|
else if len == 1
|
||||||
just = i: let
|
then list.unsafeHead values
|
||||||
split = list.splitAt i values;
|
else if list.all (canMerge path) values
|
||||||
in if i > 0
|
then mergeWith' values
|
||||||
then mergeWith' split._0
|
else
|
||||||
else list.unsafeHead values;
|
optional.match mergeUntil {
|
||||||
nothing = list.unsafeHead values;
|
just = i: let
|
||||||
|
split = list.splitAt i values;
|
||||||
|
in
|
||||||
|
if i > 0
|
||||||
|
then mergeWith' split._0
|
||||||
|
else list.unsafeHead values;
|
||||||
|
nothing = list.unsafeHead values;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
canMerge ? path: v: optional.isJust (mapToSet path v),
|
||||||
|
mapToSet ? _: v: bool.toOptional (types.attrs.check v) v,
|
||||||
|
path ? [],
|
||||||
|
sets,
|
||||||
|
}:
|
||||||
|
set.mapZip (name: values:
|
||||||
|
append {
|
||||||
|
path = path ++ list.One name;
|
||||||
|
inherit canMerge mapToSet values;
|
||||||
|
})
|
||||||
|
sets;
|
||||||
|
merge = sets:
|
||||||
|
mergeWith {
|
||||||
|
inherit sets;
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
canMerge ? path: v: optional.isJust (mapToSet path v),
|
merge [
|
||||||
mapToSet ? path: v: bool.toOptional (types.attrs.check v) v,
|
baseStd
|
||||||
path ? [ ],
|
{
|
||||||
sets
|
function = {
|
||||||
}: set.mapZip (name: values: append {
|
pipe = list.foldl' (function.flip function.compose) function.id;
|
||||||
path = path ++ list.One name;
|
};
|
||||||
inherit canMerge mapToSet values;
|
set = {
|
||||||
}) sets;
|
inherit merge mergeWith;
|
||||||
merge = sets: mergeWith {
|
remap = f: s: set.fromList (list.map f (set.toList s));
|
||||||
inherit sets;
|
recursiveMap = f: s: let
|
||||||
};
|
recurse = str: s: let
|
||||||
in merge [
|
g = str1: str2:
|
||||||
baseStd
|
if types.attrs.check str2
|
||||||
{
|
then f (str ++ [str1]) (recurse (str ++ [str1]) str2)
|
||||||
function = {
|
else f (str ++ [str1]) str2;
|
||||||
pipe = list.foldl' (function.flip function.compose) function.id;
|
in
|
||||||
};
|
set.map g s;
|
||||||
set = {
|
|
||||||
inherit merge mergeWith;
|
|
||||||
remap = f: s: set.fromList (list.map f (set.toList s));
|
|
||||||
recursiveMap = f: s: let
|
|
||||||
recurse = str: s: let
|
|
||||||
g = str1: str2:
|
|
||||||
if types.attrs.check str2
|
|
||||||
then f (str ++ [str1]) (recurse (str ++ [str1]) str2)
|
|
||||||
else f (str ++ [str1]) str2;
|
|
||||||
in
|
in
|
||||||
set.map g s;
|
f [] (recurse [] s);
|
||||||
in
|
};
|
||||||
f [] (recurse [] s);
|
}
|
||||||
};
|
];
|
||||||
}
|
in
|
||||||
];
|
std
|
||||||
in std
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
}: let
|
}: let
|
||||||
# The purpose of this file is to set up the host module which allows assigning of the system, e.g. aarch64-linux and the builder used with less pain.
|
# The purpose of this file is to set up the host module which allows assigning of the system, e.g. aarch64-linux and the builder used with less pain.
|
||||||
inherit (lib.modules) evalModules;
|
inherit (lib.modules) evalModules;
|
||||||
inherit (std) string list function types bool optional set;
|
inherit (std) string types optional set;
|
||||||
defaultSpecialArgs = {
|
defaultSpecialArgs = {
|
||||||
inherit inputs tree std;
|
inherit inputs tree std;
|
||||||
};
|
};
|
||||||
|
|
@ -106,6 +106,27 @@
|
||||||
processHost = name: cfg: let
|
processHost = name: cfg: let
|
||||||
host = cfg.config;
|
host = cfg.config;
|
||||||
in {
|
in {
|
||||||
|
deploy.nodes = set.merge [
|
||||||
|
(set.optional (host.folder == "nixos") {
|
||||||
|
${name} = {
|
||||||
|
profiles.system = {
|
||||||
|
user = "root";
|
||||||
|
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos inputs.self.nixosConfigurations.${name};
|
||||||
|
};
|
||||||
|
hostname = "${name}.inskip.me";
|
||||||
|
sshOpts = ["-p" "${builtins.toString (builtins.head inputs.self.nixosConfigurations.${name}.config.services.openssh.ports)}"];
|
||||||
|
sshUser = "kat";
|
||||||
|
user = "root";
|
||||||
|
autoRollback = true;
|
||||||
|
magicRollback = true;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
(set.optional (host.folder == "nixos" && host.arch != "x86_64") {
|
||||||
|
${name} = {
|
||||||
|
remoteBuild = true;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
"${host.folder}Configurations".${name} = let
|
"${host.folder}Configurations".${name} = let
|
||||||
hostConfig = host.builder {
|
hostConfig = host.builder {
|
||||||
inherit (host) system modules specialArgs;
|
inherit (host) system modules specialArgs;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue