Switch 17 flake inputs to npins for faster nix evaluation

flake.lock: 87 → 8 nodes (1595 → 164 lines)

Only 6 flake inputs remain: flake-parts, nixpkgs, nix-darwin,
home-manager, nixos-unified, agenix. Everything else is pinned
via npins and lazily evaluated through flake-compat, so
`nix develop` and `nix run` no longer fetch/resolve 80+ transitive
dependency nodes.

Modules are unchanged — npins-derived inputs are merged into the
`inputs` attrset passed to mkFlake, preserving the existing
`flake.inputs.foo` / `inputs.foo` interface.
This commit is contained in:
Sridhar Ratnakumar 2026-03-28 10:33:16 -04:00
parent 35ac61cfdc
commit e152445ec8
6 changed files with 545 additions and 1483 deletions

2
.gitattributes vendored
View file

@ -1,2 +1,4 @@
flake.lock linguist-generated=true
*.age linguist-generated=true
npins/default.nix linguist-generated=true
npins/sources.json linguist-generated=true

1445
flake.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,63 +1,67 @@
{
description = "Srid's NixOS / nix-darwin configuration";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
# Principle inputs
# Principle inputs (kept minimal to speed up nix develop/run/shell)
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-darwin.url = "github:LnL7/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/master";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware";
nixos-unified.url = "github:srid/nixos-unified";
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
agenix.url = "github:ryantm/agenix";
agenix.inputs = {
darwin.follows = "nix-darwin";
home-manager.follows = "home-manager";
nixpkgs.follows = "nixpkgs";
};
# Software inputs
github-nix-ci.url = "github:juspay/github-nix-ci";
nixos-vscode-server.flake = false;
nixos-vscode-server.url = "github:nix-community/nixos-vscode-server";
nix-index-database.url = "github:nix-community/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
# vira.url = "github:juspay/vira/github";
vira.url = "github:juspay/vira";
oc.url = "github:juspay/AI";
# landrun-nix.url = "github:srid/landrun-nix";
landrun-nix.url = "github:adrian-gierakowski/landrun-nix/darwin-implementation-via-sandbox-exec";
nix-agent-wire.url = "github:srid/nix-agent-wire";
jumphost-nix.url = "github:srid/jumphost-nix";
jumphost-nix.flake = false;
# KOLU
kolu.url = "github:juspay/kolu";
skills.url = "github:juspay/skills";
skills.flake = false;
# Neovim
nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
# Emanote & Imako
emanote.url = "github:srid/emanote";
imako.url = "github:srid/imako";
disc-scrape.url = "github:srid/disc-scrape";
# Devshell
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.flake = false;
# Everything else is managed by npins (see ./npins/)
};
outputs = inputs@{ self, ... }:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
outputs = flakeInputs@{ self, ... }:
let
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;
# Wrap a source path to behave like a `flake = false` input
# (supports both string interpolation and .outPath access)
wrapSource = src: { outPath = src; };
# Build an inputs-like attrset from npins sources.
# Modules continue to use `inputs.foo` / `flake.inputs.foo` unchanged.
npinsInputs = {
# Source-only inputs (formerly flake = false)
nixos-vscode-server = wrapSource sources.nixos-vscode-server;
skills = wrapSource sources.skills;
git-hooks = wrapSource sources.git-hooks;
jumphost-nix = wrapSource sources.jumphost-nix;
# 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
flakeInputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
imports = (with builtins;
map

View file

@ -14,12 +14,8 @@
"nixpkgs"
"home-manager"
"nix-darwin"
# "nixos-hardware"
"nix-index-database"
# "nixvim"
"oc"
"nix-agent-wire"
"skills"
# Other inputs are managed by npins (see ./npins/)
# Update them with: npins update
];
};
};

249
npins/default.nix generated Normal file
View file

@ -0,0 +1,249 @@
/*
This file is provided under the MIT licence:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
# Generated by npins. Do not modify; will be overwritten regularly
let
# Backwards-compatibly make something that previously didn't take any arguments take some
# The function must return an attrset, and will unfortunately be eagerly evaluated
# Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments
mkFunctor =
fn:
let
e = builtins.tryEval (fn { });
in
(if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; };
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range =
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatStrings = builtins.concatStringsSep "";
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
# (Taken from Niv for compatibility)
mayOverride =
name: path:
let
envVarName = "NPINS_OVERRIDE_${saneName}";
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
ersatz = builtins.getEnv envVarName;
in
if ersatz == "" then
path
else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
if builtins.substring 0 1 ersatz == "/" then
/. + ersatz
else
/. + builtins.getEnv "PWD" + "/${ersatz}"
);
mkSource =
name: spec:
{
pkgs ? null,
}:
assert spec ? type;
let
# Unify across builtin and pkgs fetchers.
# `fetchGit` requires a wrapper because of slight API differences.
fetchers =
if pkgs == null then
{
inherit (builtins) fetchTarball fetchurl;
# For some fucking reason, fetchGit has a different signature than the other builtin fetchers …
fetchGit = args: (builtins.fetchGit args).outPath;
}
else
{
fetchTarball =
{
url,
sha256,
}:
pkgs.fetchzip {
inherit url sha256;
extension = "tar";
};
inherit (pkgs) fetchurl;
fetchGit =
{
url,
submodules,
rev,
name,
narHash,
}:
pkgs.fetchgit {
inherit url rev name;
fetchSubmodules = submodules;
hash = narHash;
};
};
# Dispatch to the correct code path based on the type
path =
if spec.type == "Git" then
mkGitSource fetchers spec
else if spec.type == "GitRelease" then
mkGitSource fetchers spec
else if spec.type == "PyPi" then
mkPyPiSource fetchers spec
else if spec.type == "Channel" then
mkChannelSource fetchers spec
else if spec.type == "Tarball" then
mkTarballSource fetchers spec
else if spec.type == "Container" then
mkContainerSource pkgs spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = mayOverride name path; };
mkGitSource =
{
fetchTarball,
fetchGit,
...
}:
{
repository,
revision,
url ? null,
submodules,
hash,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null && !submodules then
fetchTarball {
inherit url;
sha256 = hash;
}
else
let
url =
if repository.type == "Git" then
repository.url
else if repository.type == "GitHub" then
"https://github.com/${repository.owner}/${repository.repo}.git"
else if repository.type == "GitLab" then
"${repository.server}/${repository.repo_path}.git"
else if repository.type == "Forgejo" then
"${repository.server}/${repository.owner}/${repository.repo}.git"
else
throw "Unrecognized repository type ${repository.type}";
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName url revision;
in
fetchGit {
rev = revision;
narHash = hash;
inherit name submodules url;
};
mkPyPiSource =
{ fetchurl, ... }:
{
url,
hash,
...
}:
fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource =
{ fetchTarball, ... }:
{
url,
hash,
...
}:
fetchTarball {
inherit url;
sha256 = hash;
};
mkTarballSource =
{ fetchTarball, ... }:
{
url,
locked_url ? url,
hash,
...
}:
fetchTarball {
url = locked_url;
sha256 = hash;
};
mkContainerSource =
pkgs:
{
image_name,
image_tag,
image_digest,
...
}:
if pkgs == null then
builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers"
else
pkgs.dockerTools.pullImage {
imageName = image_name;
imageDigest = image_digest;
finalImageTag = image_tag;
};
in
mkFunctor (
{
input ? ./sources.json,
}:
let
data =
if builtins.isPath input then
# while `readFile` will throw an error anyways if the path doesn't exist,
# we still need to check beforehand because *our* error can be caught but not the one from the builtin
# *piegames sighs*
if builtins.pathExists input then
builtins.fromJSON (builtins.readFile input)
else
throw "Input path ${toString input} does not exist"
else if builtins.isAttrs input then
input
else
throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset";
version = data.version;
in
if version == 7 then
builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
)

242
npins/sources.json generated Normal file
View file

@ -0,0 +1,242 @@
{
"pins": {
"disc-scrape": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "srid",
"repo": "disc-scrape"
},
"branch": "main",
"submodules": false,
"revision": "382c7e59cba9408b3098d7f0b8d10da01721b265",
"url": "https://github.com/srid/disc-scrape/archive/382c7e59cba9408b3098d7f0b8d10da01721b265.tar.gz",
"hash": "sha256-Kwx5duhBTRAAqY6UdYYGRSacT5o8//YlmwSJlzAg5d0="
},
"disko": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "disko"
},
"branch": "master",
"submodules": false,
"revision": "7b9f7f88ab3b339f8142dc246445abb3c370d3d3",
"url": "https://github.com/nix-community/disko/archive/7b9f7f88ab3b339f8142dc246445abb3c370d3d3.tar.gz",
"hash": "sha256-khlHllTsovXgT2GZ0WxT4+RvuMjNeR5OW0UYeEHPYQo="
},
"emanote": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "srid",
"repo": "emanote"
},
"branch": "master",
"submodules": false,
"revision": "6deb47e5db07221709d5214820ff4456e2bda92d",
"url": "https://github.com/srid/emanote/archive/6deb47e5db07221709d5214820ff4456e2bda92d.tar.gz",
"hash": "sha256-2y58CyRlcPIQgVvPxsxKOp6aFO6S16CyYOJxFfBaKE8="
},
"flake-compat": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "edolstra",
"repo": "flake-compat"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"submodules": false,
"version": "v1.1.0",
"revision": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"url": "https://api.github.com/repos/edolstra/flake-compat/tarball/refs/tags/v1.1.0",
"hash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU="
},
"git-hooks": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "cachix",
"repo": "git-hooks.nix"
},
"branch": "master",
"submodules": false,
"revision": "6e34e97ed9788b17796ee43ccdbaf871a5c2b476",
"url": "https://github.com/cachix/git-hooks.nix/archive/6e34e97ed9788b17796ee43ccdbaf871a5c2b476.tar.gz",
"hash": "sha256-+eXlIc4/7dE6EcPs9a2DaSY3fTA9AE526hGqkNID3Wg="
},
"github-nix-ci": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "juspay",
"repo": "github-nix-ci"
},
"branch": "main",
"submodules": false,
"revision": "edd0486a9208524eff40712a8ce835260c5b412a",
"url": "https://github.com/juspay/github-nix-ci/archive/edd0486a9208524eff40712a8ce835260c5b412a.tar.gz",
"hash": "sha256-S4Oe9aZK/UnWuj6zUlVeSDmC/QjEPHJm2gaSk/VMir4="
},
"imako": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "srid",
"repo": "imako"
},
"branch": "master",
"submodules": false,
"revision": "5ac0382b0795f0897eea866fe335586a3083bc9c",
"url": "https://github.com/srid/imako/archive/5ac0382b0795f0897eea866fe335586a3083bc9c.tar.gz",
"hash": "sha256-rZgwvE39JAOD9iod9i/7v66Il7egKoSl1zDW3EGMHoo="
},
"jumphost-nix": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "srid",
"repo": "jumphost-nix"
},
"branch": "main",
"submodules": false,
"revision": "77fc2b85b3c7a830f2ae7ab0b6716b10e0b480f1",
"url": "https://github.com/srid/jumphost-nix/archive/77fc2b85b3c7a830f2ae7ab0b6716b10e0b480f1.tar.gz",
"hash": "sha256-6oHN28aCD0jsBxliKfwdjUoHuhAMZgTRZJmllyDgDKA="
},
"kolu": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "juspay",
"repo": "kolu"
},
"branch": "main",
"submodules": false,
"revision": "575b3c18672e6a31784046d5e1c777242ab5f886",
"url": "https://github.com/juspay/kolu/archive/575b3c18672e6a31784046d5e1c777242ab5f886.tar.gz",
"hash": "sha256-YmAU9cLTccojhqkGFZdm0L/dbZkPw7sPJxo6uirlsto="
},
"landrun-nix": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "adrian-gierakowski",
"repo": "landrun-nix"
},
"branch": "darwin-implementation-via-sandbox-exec",
"submodules": false,
"revision": "664d588939df5f6d7be80c99175decf7ee5de498",
"url": "https://github.com/adrian-gierakowski/landrun-nix/archive/664d588939df5f6d7be80c99175decf7ee5de498.tar.gz",
"hash": "sha256-rKYiBL0KOtMfkgJCGxsICCvXLsqj/dzsF5seimW3edA="
},
"nix-agent-wire": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "srid",
"repo": "nix-agent-wire"
},
"branch": "main",
"submodules": false,
"revision": "dff0e61fa1bc8457815c8cd61808ea07b514502b",
"url": "https://github.com/srid/nix-agent-wire/archive/dff0e61fa1bc8457815c8cd61808ea07b514502b.tar.gz",
"hash": "sha256-YiOXMLnjkmUcubkxPWx5vRl+OaQwaJvrjiAVw8pp+u8="
},
"nix-index-database": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "nix-index-database"
},
"branch": "main",
"submodules": false,
"revision": "55b588747fa3d7fc351a11831c4b874dab992862",
"url": "https://github.com/nix-community/nix-index-database/archive/55b588747fa3d7fc351a11831c4b874dab992862.tar.gz",
"hash": "sha256-gdYe9wTPl4ignDyXUl1LlICWj41+S0GB5lG1fKP17+A="
},
"nixos-hardware": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "NixOS",
"repo": "nixos-hardware"
},
"branch": "master",
"submodules": false,
"revision": "3966ce987e1a9a164205ac8259a5fe8a64528f72",
"url": "https://github.com/NixOS/nixos-hardware/archive/3966ce987e1a9a164205ac8259a5fe8a64528f72.tar.gz",
"hash": "sha256-mUJxsNOrBMNOUJzN0pfdVJ1r2pxeqm9gI/yIKXzVVbk="
},
"nixos-vscode-server": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "nixos-vscode-server"
},
"branch": "master",
"submodules": false,
"revision": "92ce71c3ba5a94f854e02d57b14af4997ab54ef0",
"url": "https://github.com/nix-community/nixos-vscode-server/archive/92ce71c3ba5a94f854e02d57b14af4997ab54ef0.tar.gz",
"hash": "sha256-yHmd2B13EtBUPLJ+x0EaBwNkQr9LTne1arLVxT6hSnY="
},
"nixvim": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "nixvim"
},
"branch": "main",
"submodules": false,
"revision": "21ae25e13b01d3b4cdc750b5f9e7bad68b150c10",
"url": "https://github.com/nix-community/nixvim/archive/21ae25e13b01d3b4cdc750b5f9e7bad68b150c10.tar.gz",
"hash": "sha256-3DmCFOdmbkFML1/G9gj8Wb+rCCZFPOQtNoMCpqOF8SA="
},
"oc": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "juspay",
"repo": "AI"
},
"branch": "main",
"submodules": false,
"revision": "510c5a622a060adb18689b4edf5c71023780ed11",
"url": "https://github.com/juspay/AI/archive/510c5a622a060adb18689b4edf5c71023780ed11.tar.gz",
"hash": "sha256-aI9fiMRUsvKx3P3PibOp+Ony9N/mY2OllT8NOYXJjTU="
},
"skills": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "juspay",
"repo": "skills"
},
"branch": "main",
"submodules": false,
"revision": "c727a563bcd073303681aff53947e56159e6d548",
"url": "https://github.com/juspay/skills/archive/c727a563bcd073303681aff53947e56159e6d548.tar.gz",
"hash": "sha256-nT9po9XMjJ2nazyGrz8jkj75KIS8VUbnNfAYL2YqjWY="
},
"vira": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "juspay",
"repo": "vira"
},
"branch": "main",
"submodules": false,
"revision": "858ab06405097224f6841450c323f6bff21e62be",
"url": "https://github.com/juspay/vira/archive/858ab06405097224f6841450c323f6bff21e62be.tar.gz",
"hash": "sha256-PQMgtlst98me4JSJarU1R+HMQDqxIf/AzJg/mm0eSa8="
}
},
"version": 7
}