refactor some nix code with pipe
This commit is contained in:
parent
07546c9567
commit
36f623a93a
4 changed files with 72 additions and 69 deletions
89
flake.nix
89
flake.nix
|
|
@ -184,7 +184,7 @@
|
|||
imports = [
|
||||
inputs.home-manager.flakeModules.home-manager
|
||||
];
|
||||
perSystem = (
|
||||
perSystem =
|
||||
{ pkgs, system, ... }@args:
|
||||
{
|
||||
_module.args.pkgs = import inputs.nixpkgs {
|
||||
|
|
@ -199,8 +199,7 @@
|
|||
inherit inputs;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
flake =
|
||||
{
|
||||
nix.settings = {
|
||||
|
|
@ -233,16 +232,11 @@
|
|||
nixosConfigurations =
|
||||
let
|
||||
nixosConfigDir = ./nixos/configurations;
|
||||
in
|
||||
nixpkgs.lib.genAttrs
|
||||
(map (f: nixpkgs.lib.removeSuffix ".nix" f) (builtins.attrNames (builtins.readDir nixosConfigDir)))
|
||||
(
|
||||
makeNixConfiguration =
|
||||
hostName:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
modules =
|
||||
[
|
||||
outputs.nixosModules.default
|
||||
]
|
||||
[ outputs.nixosModules.default ]
|
||||
++ [
|
||||
(
|
||||
let
|
||||
|
|
@ -252,11 +246,18 @@
|
|||
if builtins.pathExists dirPath then dirPath else filePath
|
||||
)
|
||||
];
|
||||
specialArgs = {
|
||||
inherit inputs outputs rootPath;
|
||||
};
|
||||
}
|
||||
);
|
||||
specialArgs = { inherit inputs outputs rootPath; };
|
||||
};
|
||||
in
|
||||
nixosConfigDir
|
||||
|> builtins.readDir
|
||||
|> builtins.attrNames
|
||||
|> map (f: nixpkgs.lib.removeSuffix ".nix" f)
|
||||
|> map (name: {
|
||||
inherit name;
|
||||
value = makeNixConfiguration name;
|
||||
})
|
||||
|> builtins.listToAttrs;
|
||||
}
|
||||
// (
|
||||
let
|
||||
|
|
@ -313,25 +314,22 @@
|
|||
extra = import ./home/extra;
|
||||
}
|
||||
// (
|
||||
let
|
||||
allEntries = builtins.readDir ./home;
|
||||
allUsers = nixpkgs.lib.filterAttrs (
|
||||
key: value:
|
||||
value == "directory"
|
||||
&& (
|
||||
!builtins.elem key [
|
||||
"modules"
|
||||
"extra"
|
||||
]
|
||||
)
|
||||
) allEntries;
|
||||
in
|
||||
builtins.listToAttrs (
|
||||
map (name: {
|
||||
name = name;
|
||||
value = import "${toString ./home}/${name}/modules";
|
||||
}) (builtins.attrNames allUsers)
|
||||
./home
|
||||
|> builtins.readDir
|
||||
|> nixpkgs.lib.filterAttrs (key: value: value == "directory")
|
||||
|> nixpkgs.lib.filterAttrs (
|
||||
key: value:
|
||||
!builtins.elem key [
|
||||
"modules"
|
||||
"extra"
|
||||
]
|
||||
)
|
||||
|> builtins.attrNames
|
||||
|> map (name: {
|
||||
name = name;
|
||||
value = import "${toString ./home}/${name}/modules";
|
||||
})
|
||||
|> builtins.listToAttrs
|
||||
);
|
||||
}
|
||||
)
|
||||
|
|
@ -361,19 +359,18 @@
|
|||
};
|
||||
in
|
||||
{
|
||||
deploy.nodes = nixpkgs.lib.foldr (a: b: a // b) { } (
|
||||
map
|
||||
(
|
||||
hostName:
|
||||
mkDeployNode {
|
||||
inherit hostName;
|
||||
}
|
||||
)
|
||||
[
|
||||
"Cape"
|
||||
"Akun"
|
||||
]
|
||||
);
|
||||
deploy.nodes =
|
||||
[
|
||||
"Cape"
|
||||
"Akun"
|
||||
]
|
||||
|> map (
|
||||
hostName:
|
||||
mkDeployNode {
|
||||
inherit hostName;
|
||||
}
|
||||
)
|
||||
|> nixpkgs.lib.foldr (a: b: a // b) { };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
final: prev:
|
||||
let
|
||||
inherit (prev) lib;
|
||||
overlay-files = [
|
||||
./spotify.nix
|
||||
./niri.nix
|
||||
./ghostty.nix
|
||||
./juicity.nix
|
||||
./dae.nix
|
||||
./jujutsu.nix
|
||||
];
|
||||
overlay-list = map (file: import file args) overlay-files;
|
||||
in
|
||||
(lib.composeManyExtensions overlay-list) final prev
|
||||
[
|
||||
./spotify.nix
|
||||
./niri.nix
|
||||
./ghostty.nix
|
||||
./juicity.nix
|
||||
./dae.nix
|
||||
./jujutsu.nix
|
||||
]
|
||||
|> map (file: import file args)
|
||||
|> (overlays: (lib.composeManyExtensions overlays) final prev)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ let
|
|||
delve
|
||||
lldb
|
||||
rust-analyzer
|
||||
nil
|
||||
# nil
|
||||
haskell-language-server
|
||||
neocmakelsp
|
||||
]
|
||||
|
|
|
|||
|
|
@ -61,20 +61,26 @@ let
|
|||
runHook postFixup
|
||||
'';
|
||||
};
|
||||
grammars = lib.filterAttrs (key: _: lib.hasPrefix "tree-sitter-" key) srcs;
|
||||
grammars = srcs |> lib.filterAttrs (key: _: lib.hasPrefix "tree-sitter-" key);
|
||||
|
||||
queries = lib.mapAttrsToList (_: value: ''
|
||||
mkdir -p $out/${value.name}
|
||||
queries =
|
||||
grammars
|
||||
|> lib.mapAttrsToList (
|
||||
_: value: ''
|
||||
mkdir -p $out/${value.name}
|
||||
|
||||
ln -s ${value.src}/queries/* $out/${value.name}/
|
||||
'') grammars;
|
||||
builtGrammars = builtins.mapAttrs (_: v: {
|
||||
inherit (v) name;
|
||||
value = buildGrammar v;
|
||||
}) grammars;
|
||||
grammarLinks = lib.mapAttrsToList (
|
||||
_: value: "ln -s ${value.value}/${value.name}.so $out/${value.name}.so"
|
||||
) builtGrammars;
|
||||
ln -s ${value.src}/queries/* $out/${value.name}/
|
||||
''
|
||||
);
|
||||
grammarLinks =
|
||||
grammars
|
||||
|> builtins.mapAttrs (
|
||||
_: v: {
|
||||
inherit (v) name;
|
||||
value = buildGrammar v;
|
||||
}
|
||||
)
|
||||
|> lib.mapAttrsToList (_: value: "ln -s ${value.value}/${value.name}.so $out/${value.name}.so");
|
||||
grammarDir = runCommandNoCCLocal "helix-grammars" { } ''
|
||||
mkdir -p $out
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue