flake: switch to npins

Signed-off-by: Bloxx12 <charlie@charlieroot.dev>
Change-Id: I6a6a6964f4aa3349951fe7574622564452ad1af1
This commit is contained in:
Bloxx12 2025-07-19 21:51:37 +02:00
commit 0b82c15255
Signed by: faukah
SSH key fingerprint: SHA256:jpYIt4Vkz1NBTQcks/N9OPTfTFxE6KF2W/rV7hrfrIw
24 changed files with 707 additions and 731 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

40
default.nix Normal file
View file

@ -0,0 +1,40 @@
let
inherit (builtins) mapAttrs;
inherit (builtins) filter;
inherit (builtins) currentSystem;
# https://github.com/andir/npins?tab=readme-ov-file#using-the-nixpkgs-fetchers
src = import ./npins;
pkgs = import src.nixpkgs {};
sources = mapAttrs (k: v: v {inherit pkgs;}) src;
inherit (pkgs) lib;
inherit (lib.filesystem) listFilesRecursive;
inherit (lib.strings) hasSuffix;
mkSystem = system: hostname:
import (src.nixpkgs + "/nixos/lib/eval-config.nix") {
system = currentSystem;
specialArgs = {
inherit sources;
self = ./.;
};
modules =
[
# This is used to pre-emptively set the hostPlatform for nixpkgs.
# Also, we set the system hostname here.
{
networking.hostName = hostname;
nixpkgs.hostPlatform = system;
}
./hosts/common.nix
./hosts/${hostname}
]
++ ((listFilesRecursive ./modules)
|> filter (hasSuffix ".mod.nix"));
};
in {
temperance = mkSystem "x86_64-linux" "temperance";
hermit = mkSystem "x86_64-linux" "hermit";
tower = mkSystem "aarch64-linux" "tower";
}

459
flake.lock generated
View file

@ -1,463 +1,6 @@
{ {
"nodes": { "nodes": {
"crane": { "root": {}
"locked": {
"lastModified": 1751562746,
"narHash": "sha256-smpugNIkmDeicNz301Ll1bD7nFOty97T79m4GUMUczA=",
"owner": "ipetkov",
"repo": "crane",
"rev": "aed2020fd3dc26e1e857d4107a5a67a33ab6c1fd",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"determinate": {
"inputs": {
"determinate-nixd-aarch64-darwin": "determinate-nixd-aarch64-darwin",
"determinate-nixd-aarch64-linux": "determinate-nixd-aarch64-linux",
"determinate-nixd-x86_64-darwin": [
"determinate",
"determinate-nixd-aarch64-darwin"
],
"determinate-nixd-x86_64-linux": "determinate-nixd-x86_64-linux",
"nix": "nix",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1752331782,
"narHash": "sha256-eRDO93C2dXNVoLbnNECWwGcMErDKVAXNWWy6hFMPoE8=",
"owner": "determinatesystems",
"repo": "determinate",
"rev": "33ffc091037908049e9897dc8258efae81709cfd",
"type": "github"
},
"original": {
"owner": "determinatesystems",
"repo": "determinate",
"type": "github"
}
},
"determinate-nixd-aarch64-darwin": {
"flake": false,
"locked": {
"narHash": "sha256-T/kTCi8rrh1r5XMGQBymB4Hnk/KNNGkgtgma6bXXKy0=",
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.2/macOS"
},
"original": {
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.2/macOS"
}
},
"determinate-nixd-aarch64-linux": {
"flake": false,
"locked": {
"narHash": "sha256-C+KvOykOIoXCWSsPBM2Hzy1skk2lgiKXQyb9fJdwSdQ=",
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.2/aarch64-linux"
},
"original": {
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.2/aarch64-linux"
}
},
"determinate-nixd-x86_64-linux": {
"flake": false,
"locked": {
"narHash": "sha256-cENobOVn0+FtON9bmr/QoUEpNGEyxW4YpFXkLyBTYDs=",
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.2/x86_64-linux"
},
"original": {
"type": "file",
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.2/x86_64-linux"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"determinate",
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1748821116,
"narHash": "sha256-F82+gS044J1APL0n4hH50GYdPRv/5JWm34oCJYmVKdE=",
"rev": "49f0870db23e8c1ca0b5259734a02cd9e1e371a1",
"revCount": 377,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/hercules-ci/flake-parts/0.1.377%2Brev-49f0870db23e8c1ca0b5259734a02cd9e1e371a1/01972f28-554a-73f8-91f4-d488cc502f08/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/hercules-ci/flake-parts/0.1"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"lanzaboote",
"nixpkgs"
]
},
"locked": {
"lastModified": 1751413152,
"narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "77826244401ea9de6e3bac47c2db46005e1f30b5",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"git-hooks-nix": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": [
"determinate",
"nix"
],
"nixpkgs": [
"determinate",
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1747372754,
"narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"revCount": 1026,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/cachix/git-hooks.nix/0.1.1026%2Brev-80479b6ec16fefd9c1db3ea13aeb038c60530f46/0196d79a-1b35-7b8e-a021-c894fb62163d/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/cachix/git-hooks.nix/0.1.941"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"lanzaboote",
"pre-commit-hooks-nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"impermanence": {
"locked": {
"lastModified": 1737831083,
"narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "impermanence",
"type": "github"
}
},
"lanzaboote": {
"inputs": {
"crane": "crane",
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts_2",
"nixpkgs": [
"nixpkgs"
],
"pre-commit-hooks-nix": "pre-commit-hooks-nix",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1752673703,
"narHash": "sha256-9Cc0YqL9ZUpaybJsrRJfXex91QlPmQNqpTLgw/KvJGA=",
"owner": "nix-community",
"repo": "lanzaboote",
"rev": "5a776450d904b7ccd377c2a759703152b2553e98",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "lanzaboote",
"type": "github"
}
},
"nix": {
"inputs": {
"flake-parts": "flake-parts",
"git-hooks-nix": "git-hooks-nix",
"nixpkgs": "nixpkgs",
"nixpkgs-23-11": "nixpkgs-23-11",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1752329813,
"narHash": "sha256-+PLMYzOLXmYtGUcUxIbJZpadAV/gO73EAhISc1kgvJM=",
"rev": "04045d5add7915ea9209a09833fae1aa3a3a9be1",
"revCount": 21488,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nix-src/3.8.2/0197ff19-42da-7beb-b8cf-902b39687ccf/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/DeterminateSystems/nix-src/%2A"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1747179050,
"narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=",
"rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e",
"revCount": 799423,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.799423%2Brev-adaa24fbf46737f3f1b5497bf64bae750f82942e/0196d1c3-1974-7bf1-bcf6-06620ac40c8c/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/%3D0.1.799423"
}
},
"nixpkgs-23-11": {
"locked": {
"lastModified": 1717159533,
"narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 315532800,
"narHash": "sha256-aW0rd3E6pilfWXcNrMwbA4ehW3BZJ0oep4LQbUgOrgg=",
"rev": "fa0ef8a6bb1651aa26c939aeb51b5f499e86b0ec",
"type": "tarball",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre831232.fa0ef8a6bb16/nixexprs.tar.xz"
},
"original": {
"type": "tarball",
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
}
},
"pre-commit-hooks-nix": {
"inputs": {
"flake-compat": [
"lanzaboote",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"lanzaboote",
"nixpkgs"
]
},
"locked": {
"lastModified": 1750779888,
"narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"quickshell": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1752837946,
"narHash": "sha256-oLkH/Mr0cfrjD6WRf6GqJV6sizX0ZgYqD6gFdziyKVo=",
"ref": "refs/heads/master",
"rev": "e55d519c280192d8d97695b6c5905a0d7a46f8fe",
"revCount": 647,
"type": "git",
"url": "https://git.outfoxxed.me/outfoxxed/quickshell"
},
"original": {
"type": "git",
"url": "https://git.outfoxxed.me/outfoxxed/quickshell"
}
},
"root": {
"inputs": {
"determinate": "determinate",
"impermanence": "impermanence",
"lanzaboote": "lanzaboote",
"nixpkgs": "nixpkgs_2",
"quickshell": "quickshell",
"spicetify-nix": "spicetify-nix",
"systems": "systems",
"watt": "watt"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"lanzaboote",
"nixpkgs"
]
},
"locked": {
"lastModified": 1751769931,
"narHash": "sha256-QR2Rp/41NkA5YxcpvZEKD1S2QE1Pb9U415aK8M/4tJc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "3ac4f630e375177ea8317e22f5c804156de177e8",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"spicetify-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1752381641,
"narHash": "sha256-R2iDZb94RosuCeuIukacZVVXxzWYr4jn/QI/ax15nW8=",
"owner": "Gerg-L",
"repo": "spicetify-nix",
"rev": "8f9fd947c52aa6adb6bafe72516eccf186708954",
"type": "github"
},
"original": {
"owner": "Gerg-L",
"repo": "spicetify-nix",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"watt": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1749377316,
"narHash": "sha256-hw3rL4rlIlYJMTeE7DlQ3lRhQDJURAhE+PC/NT4VAAQ=",
"owner": "notashelf",
"repo": "watt",
"rev": "154724c7b1bd49654ea55df719e1eb3219ec2000",
"type": "github"
},
"original": {
"owner": "notashelf",
"repo": "watt",
"type": "github"
}
}
}, },
"root": "root", "root": "root",
"version": 7 "version": 7

View file

@ -1,11 +1,18 @@
{ {
description = "My NixOS config flake"; description = "My NixOS config flake";
outputs = inputs: let
inherit (inputs.nixpkgs) lib; # No inputs, take this flakers
eachSystem = lib.genAttrs (import inputs.systems);
pkgsFor = inputs.nixpkgs.legacyPackages; outputs = _: let
sources = import ./npins;
nixpkgs = (import sources.flake-compat {src = sources.nixpkgs;}).outputs;
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import sources.systems);
pkgsFor = nixpkgs.legacyPackages;
inputs = sources;
in { in {
nixosConfigurations = import ./hosts inputs; nixosConfigurations = import ./default.nix;
formatter = eachSystem (system: pkgsFor.${system}.alejandra); formatter = eachSystem (system: pkgsFor.${system}.alejandra);
@ -24,6 +31,18 @@
} }
) )
pkgsFor; pkgsFor;
devShells =
lib.mapAttrs (
_: pkgs: {
default = pkgs.mkShellNoCC {
packages = [
(pkgs.callPackage (sources.npins + "/npins.nix") {})
];
env.NPINS_OVERRIDE_nichts = ".";
};
}
)
pkgsFor;
apps = eachSystem (system: let apps = eachSystem (system: let
inherit (inputs.self.packages.${system}) fish helix nushell; inherit (inputs.self.packages.${system}) fish helix nushell;
@ -45,43 +64,4 @@
templates = import ./templates; templates = import ./templates;
}; };
inputs = {
# Unstable nixpkgs, using the new Lockable HTTP Tarball protocol
# https://github.com/NixOS/infra/pull/562.
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
systems.url = "github:nix-systems/default-linux";
impermanence.url = "github:nix-community/impermanence";
watt = {
url = "github:notashelf/watt";
inputs.nixpkgs.follows = "nixpkgs";
};
spicetify-nix = {
url = "github:Gerg-L/spicetify-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
quickshell = {
# add ?ref=<tag> to track a tag
url = "git+https://git.outfoxxed.me/outfoxxed/quickshell";
# THIS IS IMPORTANT
# Mismatched system dependencies will lead to crashes and other issues.
inputs.nixpkgs.follows = "nixpkgs";
};
# secure booting
lanzaboote = {
url = "github:nix-community/lanzaboote";
inputs.nixpkgs.follows = "nixpkgs";
};
# DetNix is doing too well these days not to use it.
determinate = {
url = "github:determinatesystems/determinate";
inputs.nixpkgs.follows = "nixpkgs";
};
};
} }

View file

@ -9,7 +9,8 @@
... ...
}: let }: let
inherit (lib.meta) hiPrioSet; inherit (lib.meta) hiPrioSet;
inherit (self.packages.${pkgs.stdenv.system}) helix fish; helix = pkgs.callPackage (self + "/packages/helix") {};
fish = pkgs.callPackage (self + "/packages/fish") {};
in { in {
environment.systemPackages = environment.systemPackages =
builtins.attrValues { builtins.attrValues {

View file

@ -1,7 +1,11 @@
inputs: let {
inherit (inputs) self; sources,
nixpkgs,
self,
...
}: let
inherit (builtins) filter map toString; inherit (builtins) filter map toString;
inherit (inputs.nixpkgs) lib; inherit (nixpkgs) lib;
inherit (lib.attrsets) recursiveUpdate; inherit (lib.attrsets) recursiveUpdate;
inherit (lib.filesystem) listFilesRecursive; inherit (lib.filesystem) listFilesRecursive;
inherit (lib.lists) concatLists flatten singleton; inherit (lib.lists) concatLists flatten singleton;
@ -20,7 +24,7 @@ inputs: let
recursiveUpdate recursiveUpdate
{ {
inherit lib; inherit lib;
inherit inputs; inputs = sources;
inherit self; inherit self;
} }
args.specialArgs or {}; args.specialArgs or {};

View file

@ -9,6 +9,7 @@
bubblewrap bubblewrap
cachix cachix
calc calc
emacs
calibre calibre
carapace carapace
comma comma

View file

@ -8,8 +8,9 @@
inherit (builtins) elemAt; inherit (builtins) elemAt;
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) listOf str package; inherit (lib.types) listOf str package;
inherit (config.meta.mainUser) username; inherit (config.meta.mainUser) username;
nushell = pkgs.callPackage (self + "/packages/nushell") {};
in { in {
options.meta = { options.meta = {
users = mkOption { users = mkOption {
@ -49,7 +50,7 @@ in {
}; };
package = mkOption { package = mkOption {
type = package; type = package;
default = self.packages.${pkgs.stdenv.system}.nushell; default = nushell;
}; };
}; };
}; };
@ -69,7 +70,7 @@ in {
"nix" "nix"
"docker" "docker"
]; ];
shell = self.packages.${pkgs.stdenv.system}.nushell; shell = nushell;
}; };
}; };
}; };

View file

@ -1,32 +1,8 @@
{ {pkgs, ...}: {
inputs,
pkgs,
...
}: let
spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.stdenv.system};
spicetify = inputs.spicetify-nix.lib.mkSpicetify pkgs {
enable = true;
theme = spicePkgs.themes.catppuccin;
colorScheme = "mocha";
# enabledCustomApps = with spicePkgs.apps; [
# newReleases
# lyricsPlus
# ncsVisualizer
# ];
enabledExtensions = with spicePkgs.extensions; [
shuffle
hidePodcasts
keyboardShortcut
groupSession
keyboardShortcut
betterGenres
autoVolume
lastfm
];
};
in {
environment.systemPackages = environment.systemPackages =
[spicetify] [
pkgs.spotify
]
++ (with pkgs; [ ++ (with pkgs; [
sptlrx sptlrx
]); ]);

View file

@ -1,8 +1,8 @@
{ {
config, config,
inputs,
lib, lib,
pkgs, pkgs,
sources,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
@ -14,7 +14,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
inputs.quickshell.packages.${pkgs.stdenv.system}.quickshell (pkgs.callPackage (sources.quickshell + "/default.nix") {})
qt6.qtimageformats qt6.qtimageformats
qt6.qt5compat qt6.qt5compat
qt6.qtmultimedia qt6.qtmultimedia

View file

@ -1,8 +1,8 @@
{ {
config, config,
inputs,
lib, lib,
pkgs, pkgs,
sources,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
@ -12,7 +12,7 @@
in { in {
options.modules.system.boot.lanzaboote.enable = mkEnableOption "Lanzaboote"; options.modules.system.boot.lanzaboote.enable = mkEnableOption "Lanzaboote";
imports = [ imports = [
inputs.lanzaboote.nixosModules.lanzaboote (sources.lanzaboote + "/nix/modules/lanzaboote.nix")
]; ];
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -1,6 +1,6 @@
{ {
config, config,
inputs, sources,
lib, lib,
pkgs, pkgs,
... ...
@ -8,7 +8,7 @@
inherit (lib.modules) mkDefault; inherit (lib.modules) mkDefault;
in { in {
imports = [ imports = [
inputs.watt.nixosModules.default # (sources.watt + "/nix/module.nix")
]; ];
config = { config = {
environment.systemPackages = builtins.attrValues { environment.systemPackages = builtins.attrValues {
@ -29,182 +29,182 @@ in {
hardware.acpilight.enable = false; hardware.acpilight.enable = false;
services.watt = { # services.watt = {
enable = true; # enable = true;
# sample config from https://github.com/NotAShelf/watt#sample-configuration # # sample config from https://github.com/NotAShelf/watt#sample-configuration
settings = { # settings = {
rule = [ # rule = [
{ # {
cpu = { # cpu = {
energy-performance-preference = "power"; # energy-performance-preference = "power";
frequency-mhz-maximum = 2000; # frequency-mhz-maximum = 2000;
governor = "powersave"; # governor = "powersave";
turbo = false; # turbo = false;
}; # };
"if" = { # "if" = {
is-more-than = 85; # is-more-than = 85;
value = "$cpu-temperature"; # value = "$cpu-temperature";
}; # };
priority = 100; # priority = 100;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "power"; # energy-performance-preference = "power";
frequency-mhz-maximum = 800; # frequency-mhz-maximum = 800;
governor = "powersave"; # governor = "powersave";
turbo = false; # turbo = false;
}; # };
"if" = { # "if" = {
all = [ # all = [
"?discharging" # "?discharging"
{ # {
is-less-than = 0.3; # is-less-than = 0.3;
value = "%power-supply-charge"; # value = "%power-supply-charge";
} # }
]; # ];
}; # };
power = {platform-profile = "low-power";}; # power = {platform-profile = "low-power";};
priority = 90; # priority = 90;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "performance"; # energy-performance-preference = "performance";
governor = "performance"; # governor = "performance";
turbo = true; # turbo = true;
}; # };
"if" = { # "if" = {
all = [ # all = [
{ # {
is-more-than = 0.8; # is-more-than = 0.8;
value = "%cpu-usage"; # value = "%cpu-usage";
} # }
{ # {
is-less-than = 30; # is-less-than = 30;
value = "$cpu-idle-seconds"; # value = "$cpu-idle-seconds";
} # }
{ # {
is-less-than = 75; # is-less-than = 75;
value = "$cpu-temperature"; # value = "$cpu-temperature";
} # }
]; # ];
}; # };
priority = 80; # priority = 80;
} # }
{ # {
cpu = { # cpu = {
energy-performance-bias = "balance_performance"; # energy-performance-bias = "balance_performance";
energy-performance-preference = "performance"; # energy-performance-preference = "performance";
governor = "performance"; # governor = "performance";
turbo = true; # turbo = true;
}; # };
"if" = { # "if" = {
all = [ # all = [
{not = "?discharging";} # {not = "?discharging";}
{ # {
is-more-than = 0.1; # is-more-than = 0.1;
value = "%cpu-usage"; # value = "%cpu-usage";
} # }
{ # {
is-less-than = 80; # is-less-than = 80;
value = "$cpu-temperature"; # value = "$cpu-temperature";
} # }
]; # ];
}; # };
priority = 70; # priority = 70;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "balance_performance"; # energy-performance-preference = "balance_performance";
governor = "schedutil"; # governor = "schedutil";
}; # };
"if" = { # "if" = {
all = [ # all = [
{ # {
is-more-than = 0.4; # is-more-than = 0.4;
value = "%cpu-usage"; # value = "%cpu-usage";
} # }
{ # {
is-less-than = 0.8; # is-less-than = 0.8;
value = "%cpu-usage"; # value = "%cpu-usage";
} # }
]; # ];
}; # };
priority = 60; # priority = 60;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "power"; # energy-performance-preference = "power";
governor = "powersave"; # governor = "powersave";
turbo = false; # turbo = false;
}; # };
"if" = { # "if" = {
all = [ # all = [
{ # {
is-less-than = 0.2; # is-less-than = 0.2;
value = "%cpu-usage"; # value = "%cpu-usage";
} # }
{ # {
is-more-than = 60; # is-more-than = 60;
value = "$cpu-idle-seconds"; # value = "$cpu-idle-seconds";
} # }
]; # ];
}; # };
priority = 50; # priority = 50;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "power"; # energy-performance-preference = "power";
frequency-mhz-maximum = 1600; # frequency-mhz-maximum = 1600;
governor = "powersave"; # governor = "powersave";
turbo = false; # turbo = false;
}; # };
"if" = { # "if" = {
is-more-than = 300; # is-more-than = 300;
value = "$cpu-idle-seconds"; # value = "$cpu-idle-seconds";
}; # };
priority = 40; # priority = 40;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "power"; # energy-performance-preference = "power";
frequency-mhz-maximum = 2000; # frequency-mhz-maximum = 2000;
governor = "powersave"; # governor = "powersave";
turbo = false; # turbo = false;
}; # };
"if" = { # "if" = {
all = [ # all = [
"?discharging" # "?discharging"
{ # {
is-less-than = 0.5; # is-less-than = 0.5;
value = "%power-supply-charge"; # value = "%power-supply-charge";
} # }
]; # ];
}; # };
power = {platform-profile = "low-power";}; # power = {platform-profile = "low-power";};
priority = 30; # priority = 30;
} # }
{ # {
cpu = { # cpu = {
energy-performance-bias = "balance_power"; # energy-performance-bias = "balance_power";
energy-performance-preference = "power"; # energy-performance-preference = "power";
frequency-mhz-maximum = 1800; # frequency-mhz-maximum = 1800;
frequency-mhz-minimum = 200; # frequency-mhz-minimum = 200;
governor = "powersave"; # governor = "powersave";
turbo = false; # turbo = false;
}; # };
"if" = "?discharging"; # "if" = "?discharging";
priority = 20; # priority = 20;
} # }
{ # {
cpu = { # cpu = {
energy-performance-preference = "balance_performance"; # energy-performance-preference = "balance_performance";
governor = "schedutil"; # governor = "schedutil";
}; # };
priority = 0; # priority = 0;
} # }
]; # ];
}; # };
}; # };
services = { services = {
upower = { upower = {
enable = true; enable = true;

View file

@ -0,0 +1,61 @@
{
config,
lib,
pkgs,
sources,
...
}: let
determinate = (import sources.flake-compat {src = sources.determinate;}).outputs;
dix = (import sources.flake-compat {src = determinate.inputs.nix;}).outputs.packages.${pkgs.stdenv.system}.nix;
# Stronger than mkDefault (1000), weaker than mkForce (50) and the "default override priority"
# (100).
mkPreferable = lib.mkOverride 750;
# Stronger than the "default override priority", as the upstream module uses that, and weaker than mkForce (50).
mkMorePreferable = lib.mkOverride 75;
in {
config = {
nix = {
package = dix;
};
environment.systemPackages = [
determinate.packages.${pkgs.stdenv.system}.default
];
# NOTE(cole-h): Move the generated nix.conf to /etc/nix/nix.custom.conf, which is included from
# the Determinate Nixd-managed /etc/nix/nix.conf.
environment.etc."nix/nix.conf".target = "nix/nix.custom.conf";
systemd = {
services.nix-daemon.serviceConfig = {
ExecStart = [
""
"@${determinate.packages.${pkgs.stdenv.system}.default}/bin/determinate-nixd determinate-nixd --nix-bin ${config.nix.package}/bin daemon"
];
KillMode = mkPreferable "process";
LimitNOFILE = mkMorePreferable 1048576;
LimitSTACK = mkPreferable "64M";
TasksMax = mkPreferable 1048576;
};
sockets = {
nix-daemon.socketConfig.FileDescriptorName = "nix-daemon.socket";
determinate-nixd = {
description = "Determinate Nixd Daemon Socket";
wantedBy = ["sockets.target"];
before = ["multi-user.target"];
unitConfig = {
RequiresMountsFor = ["/nix/store" "/nix/var/determinate"];
};
socketConfig = {
Service = "nix-daemon.service";
FileDescriptorName = "determinate-nixd.socket";
ListenStream = "/nix/var/determinate/determinate-nixd.socket";
DirectoryMode = "0755";
};
};
};
};
};
}

View file

@ -1,7 +1,7 @@
# credits to raf # credits to raf
{ {
config, config,
inputs, sources,
lib, lib,
pkgs, pkgs,
... ...
@ -9,10 +9,6 @@
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
inherit (lib.modules) mkForce; inherit (lib.modules) mkForce;
in { in {
imports = [
inputs.determinate.nixosModules.default
];
nix = { nix = {
# Check that Nix can parse the generated nix.conf. # Check that Nix can parse the generated nix.conf.
checkConfig = true; checkConfig = true;
@ -25,9 +21,9 @@ in {
# this is taken from sioodmy. # this is taken from sioodmy.
# pin the registry to avoid downloading and evaling a new nixpkgs version every time # pin the registry to avoid downloading and evaling a new nixpkgs version every time
registry = # registry =
lib.mapAttrs (_: v: {flake = v;}) inputs # lib.mapAttrs (_: v: {flake = v.outPath;}) sources
// {system.flake = inputs.self;}; # // {system.flake = sources.nichts;};
# Add inputs to the system's legacy channels # Add inputs to the system's legacy channels
# to make legacy nix commands consistent as well # to make legacy nix commands consistent as well
@ -157,7 +153,7 @@ in {
]; ];
# Determinate nix config # Determinate nix config
# =========================================== # ===========================================
lazy-trees = true; # lazy-trees = true;
# =========================================== # ===========================================
}; };
}; };

View file

@ -1,8 +1,14 @@
# taken from raf # taken from raf
{ {sources, ...}: {
# Global nixpkgs configuration. # Global nixpkgs configuration.
# This is ignored if nixpkgs.pkgs is set, which should be avoided. # This is ignored if nixpkgs.pkgs is set, which should be avoided.
nixpkgs = { nixpkgs = {
flake = {
source = sources.nixpkgs;
setFlakeRegistry = true;
setNixPath = true;
};
# Configuration reference: # Configuration reference:
# <https://nixos.org/manual/nixpkgs/unstable/#chap-packageconfig> # <https://nixos.org/manual/nixpkgs/unstable/#chap-packageconfig>
config = { config = {

View file

@ -2,6 +2,7 @@
inputs, inputs,
config, config,
lib, lib,
sources,
... ...
}: let }: let
inherit (lib.modules) mkIf mkForce; inherit (lib.modules) mkIf mkForce;
@ -10,7 +11,7 @@
cfg = config.modules.system.impermanence; cfg = config.modules.system.impermanence;
in { in {
imports = [ imports = [
inputs.impermanence.nixosModules.impermanence (sources.impermanence + "/nixos.nix")
]; ];
config = mkIf cfg.enable { config = mkIf cfg.enable {
users = { users = {

210
npins/default.nix Normal file
View file

@ -0,0 +1,210 @@
/*
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));
concatMapStrings = f: list: concatStrings (map f list);
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 = pkgs.fetchzip;
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
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = mayOverride name path; };
mkGitSource =
{ fetchTarball, fetchGit, ... }:
{
repository,
revision,
url ? null,
submodules,
hash,
branch ? null,
...
}:
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
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;
};
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 == 6 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`"
)

151
npins/sources.json Normal file
View file

@ -0,0 +1,151 @@
{
"pins": {
"determinate": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "determinatesystems",
"repo": "determinate"
},
"branch": "main",
"submodules": false,
"revision": "5e73b5071ece6da51aa50c55e3438335e2ef9d9c",
"url": "https://github.com/determinatesystems/determinate/archive/5e73b5071ece6da51aa50c55e3438335e2ef9d9c.tar.gz",
"hash": "sha256-UFzMWhD4rN/9C5Rnf6VHB63gHLFgaPxh0meZlRQrbnU="
},
"dix": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "determinatesystems",
"repo": "nix-src"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"submodules": false,
"version": "v3.8.3",
"revision": "aa49e142fc30f0598f954abdc0b83c2f290f12d1",
"url": "https://api.github.com/repos/determinatesystems/nix-src/tarball/v3.8.3",
"hash": "sha256-Z+nd/hOF4mpn1OqjvtrJZAoXwiXJ36wtoubd1kAWhmE="
},
"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/v1.1.0",
"hash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU="
},
"impermanence": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "impermanence"
},
"branch": "master",
"submodules": false,
"revision": "4b3e914cdf97a5b536a889e939fb2fd2b043a170",
"url": "https://github.com/nix-community/impermanence/archive/4b3e914cdf97a5b536a889e939fb2fd2b043a170.tar.gz",
"hash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI="
},
"lanzaboote": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "lanzaboote"
},
"branch": "master",
"submodules": false,
"revision": "5a776450d904b7ccd377c2a759703152b2553e98",
"url": "https://github.com/nix-community/lanzaboote/archive/5a776450d904b7ccd377c2a759703152b2553e98.tar.gz",
"hash": "sha256-9Cc0YqL9ZUpaybJsrRJfXex91QlPmQNqpTLgw/KvJGA="
},
"nixpkgs": {
"type": "Channel",
"name": "nixpkgs-unstable",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre832020.6b4955211758/nixexprs.tar.xz",
"hash": "sha256-X3H1JILbG//yt1OHrx7GHwyIUoqmR9jXARlwbZyPF4k="
},
"nixpkgs_2": {
"type": "Tarball",
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz",
"hash": "sha256-6lH+e1WGAX7sA9ey7nEcksrMVv0ZGd5TxapjfrAIbts="
},
"npins": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "andir",
"repo": "npins"
},
"branch": "master",
"submodules": false,
"revision": "afa9fe50cb0bff9ba7e9f7796892f71722b2180d",
"url": "https://github.com/andir/npins/archive/afa9fe50cb0bff9ba7e9f7796892f71722b2180d.tar.gz",
"hash": "sha256-D6dYAMk9eYpBriE07s8Q7M3WBT7uM9pz3RKIoNk+h7I="
},
"quickshell": {
"type": "Git",
"repository": {
"type": "Git",
"url": "https://git.outfoxxed.me/outfoxxed/quickshell"
},
"branch": "master",
"submodules": false,
"revision": "759bd721dfd38e2ce02048f378ee025bcb175f93",
"url": null,
"hash": "sha256-GjN9BXxWMlmIAAcKYrsrEPVT/cJkWieG3YOJG7sJuGk="
},
"spicetify-nix": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "Gerg-L",
"repo": "spicetify-nix"
},
"branch": "master",
"submodules": false,
"revision": "8f9fd947c52aa6adb6bafe72516eccf186708954",
"url": "https://github.com/Gerg-L/spicetify-nix/archive/8f9fd947c52aa6adb6bafe72516eccf186708954.tar.gz",
"hash": "sha256-R2iDZb94RosuCeuIukacZVVXxzWYr4jn/QI/ax15nW8="
},
"systems": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-systems",
"repo": "default-linux"
},
"branch": "main",
"submodules": false,
"revision": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"url": "https://github.com/nix-systems/default-linux/archive/31732fcf5e8fea42e59c2488ad31a0e651500f68.tar.gz",
"hash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80="
},
"watt": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "notashelf",
"repo": "watt"
},
"branch": "main",
"submodules": false,
"revision": "154724c7b1bd49654ea55df719e1eb3219ec2000",
"url": "https://github.com/notashelf/watt/archive/154724c7b1bd49654ea55df719e1eb3219ec2000.tar.gz",
"hash": "sha256-hw3rL4rlIlYJMTeE7DlQ3lRhQDJURAhE+PC/NT4VAAQ="
}
},
"version": 6
}

View file

@ -315,6 +315,10 @@ if not ($env_vars_file | path exists) {
| load-env $in | load-env $in
} }
def switch [] {
nh os switch --file ($env.NH_FLAKE | path join default.nix) (open /etc/hostname)
}
# fix sudo by prepending /run/wrappers/bin to the PATH. # fix sudo by prepending /run/wrappers/bin to the PATH.
$env.PATH = ($env.PATH | split row (char esep) | prepend '/run/wrappers/bin') $env.PATH = ($env.PATH | split row (char esep) | prepend '/run/wrappers/bin')