mirror of
https://github.com/srid/nixos-config.git
synced 2026-07-16 22:01:33 +08:00
Simplify npinsInputs with mapAttrs
Replace 17 explicit callFlake/wrapSource lines with a single mapAttrs over all npins sources, using a sourceOnly list to distinguish source-only pins from flake pins.
This commit is contained in:
parent
e152445ec8
commit
51afed509e
1 changed files with 11 additions and 33 deletions
44
flake.nix
44
flake.nix
|
|
@ -24,42 +24,20 @@
|
||||||
outputs = flakeInputs@{ self, ... }:
|
outputs = flakeInputs@{ self, ... }:
|
||||||
let
|
let
|
||||||
sources = import ./npins;
|
sources = import ./npins;
|
||||||
|
|
||||||
# Lazily evaluate a flake from npins source using flake-compat.
|
|
||||||
# The flake is only fetched/evaluated when its outputs are actually used,
|
|
||||||
# so `nix develop` and `nix run` stay fast.
|
|
||||||
callFlake = src: (import sources.flake-compat { inherit src; }).defaultNix;
|
callFlake = src: (import sources.flake-compat { inherit src; }).defaultNix;
|
||||||
|
|
||||||
# Wrap a source path to behave like a `flake = false` input
|
# Source-only npins (no flake evaluation needed)
|
||||||
# (supports both string interpolation and .outPath access)
|
sourceOnly = [ "nixos-vscode-server" "skills" "git-hooks" "jumphost-nix" ];
|
||||||
wrapSource = src: { outPath = src; };
|
|
||||||
|
|
||||||
# Build an inputs-like attrset from npins sources.
|
# Merge npins-derived inputs with real flake inputs.
|
||||||
# Modules continue to use `inputs.foo` / `flake.inputs.foo` unchanged.
|
# callFlake lazily evaluates via flake-compat, so `nix develop` stays fast.
|
||||||
npinsInputs = {
|
# Modules keep using `inputs.foo` / `flake.inputs.foo` unchanged.
|
||||||
# Source-only inputs (formerly flake = false)
|
inputs = flakeInputs // builtins.mapAttrs
|
||||||
nixos-vscode-server = wrapSource sources.nixos-vscode-server;
|
(name: src:
|
||||||
skills = wrapSource sources.skills;
|
if builtins.elem name sourceOnly
|
||||||
git-hooks = wrapSource sources.git-hooks;
|
then { outPath = src; }
|
||||||
jumphost-nix = wrapSource sources.jumphost-nix;
|
else callFlake src)
|
||||||
|
(removeAttrs sources [ "flake-compat" ]);
|
||||||
# Flake inputs (lazily evaluated via flake-compat)
|
|
||||||
disko = callFlake sources.disko;
|
|
||||||
disc-scrape = callFlake sources.disc-scrape;
|
|
||||||
emanote = callFlake sources.emanote;
|
|
||||||
github-nix-ci = callFlake sources.github-nix-ci;
|
|
||||||
imako = callFlake sources.imako;
|
|
||||||
kolu = callFlake sources.kolu;
|
|
||||||
landrun-nix = callFlake sources.landrun-nix;
|
|
||||||
nix-agent-wire = callFlake sources.nix-agent-wire;
|
|
||||||
nix-index-database = callFlake sources.nix-index-database;
|
|
||||||
nixos-hardware = callFlake sources.nixos-hardware;
|
|
||||||
nixvim = callFlake sources.nixvim;
|
|
||||||
oc = callFlake sources.oc;
|
|
||||||
vira = callFlake sources.vira;
|
|
||||||
};
|
|
||||||
|
|
||||||
inputs = flakeInputs // npinsInputs;
|
|
||||||
in
|
in
|
||||||
flakeInputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
flakeInputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
|
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue