diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ca462d5 --- /dev/null +++ b/default.nix @@ -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"; +} diff --git a/flake.lock b/flake.lock index fe832a9..5999137 100644 --- a/flake.lock +++ b/flake.lock @@ -1,463 +1,6 @@ { "nodes": { - "crane": { - "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", "version": 7 diff --git a/flake.nix b/flake.nix index a7166be..5824ff6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,18 @@ { description = "My NixOS config flake"; - outputs = inputs: let - inherit (inputs.nixpkgs) lib; - eachSystem = lib.genAttrs (import inputs.systems); - pkgsFor = inputs.nixpkgs.legacyPackages; + + # No inputs, take this flakers + + 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 { - nixosConfigurations = import ./hosts inputs; + nixosConfigurations = import ./default.nix; formatter = eachSystem (system: pkgsFor.${system}.alejandra); @@ -24,6 +31,18 @@ } ) pkgsFor; + devShells = + lib.mapAttrs ( + _: pkgs: { + default = pkgs.mkShellNoCC { + packages = [ + (pkgs.callPackage (sources.npins + "/npins.nix") {}) + ]; + env.NPINS_OVERRIDE_nichts = "."; + }; + } + ) + pkgsFor; apps = eachSystem (system: let inherit (inputs.self.packages.${system}) fish helix nushell; @@ -45,43 +64,4 @@ 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= 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"; - }; - }; } diff --git a/hosts/common.nix b/hosts/common.nix index 4d8b775..34a0269 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -9,7 +9,8 @@ ... }: let 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 { environment.systemPackages = builtins.attrValues { diff --git a/hosts/default.nix b/hosts/default.nix index da17b48..dfc5387 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,7 +1,11 @@ -inputs: let - inherit (inputs) self; +{ + sources, + nixpkgs, + self, + ... +}: let inherit (builtins) filter map toString; - inherit (inputs.nixpkgs) lib; + inherit (nixpkgs) lib; inherit (lib.attrsets) recursiveUpdate; inherit (lib.filesystem) listFilesRecursive; inherit (lib.lists) concatLists flatten singleton; @@ -20,7 +24,7 @@ inputs: let recursiveUpdate { inherit lib; - inherit inputs; + inputs = sources; inherit self; } args.specialArgs or {}; diff --git a/hosts/temperance/programs.nix b/hosts/temperance/programs.nix index 4d1f8bd..7e8725d 100644 --- a/hosts/temperance/programs.nix +++ b/hosts/temperance/programs.nix @@ -9,6 +9,7 @@ bubblewrap cachix calc + emacs calibre carapace comma diff --git a/modules/other/users.mod.nix b/modules/other/users.mod.nix index 569176f..908ca9d 100644 --- a/modules/other/users.mod.nix +++ b/modules/other/users.mod.nix @@ -8,8 +8,9 @@ inherit (builtins) elemAt; inherit (lib.options) mkOption; inherit (lib.types) listOf str package; - inherit (config.meta.mainUser) username; + + nushell = pkgs.callPackage (self + "/packages/nushell") {}; in { options.meta = { users = mkOption { @@ -49,7 +50,7 @@ in { }; package = mkOption { type = package; - default = self.packages.${pkgs.stdenv.system}.nushell; + default = nushell; }; }; }; @@ -69,7 +70,7 @@ in { "nix" "docker" ]; - shell = self.packages.${pkgs.stdenv.system}.nushell; + shell = nushell; }; }; }; diff --git a/modules/programs/gui/spotify.mod.nix b/modules/programs/gui/spotify.mod.nix index b0143e5..589d93f 100644 --- a/modules/programs/gui/spotify.mod.nix +++ b/modules/programs/gui/spotify.mod.nix @@ -1,32 +1,8 @@ -{ - 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 { +{pkgs, ...}: { environment.systemPackages = - [spicetify] + [ + pkgs.spotify + ] ++ (with pkgs; [ sptlrx ]); diff --git a/modules/services/forgejo/module.nix b/modules/services/forgejo/forgejo.mod.nix similarity index 100% rename from modules/services/forgejo/module.nix rename to modules/services/forgejo/forgejo.mod.nix diff --git a/modules/services/grafana/module.nix b/modules/services/grafana/grafana.mod.nix similarity index 100% rename from modules/services/grafana/module.nix rename to modules/services/grafana/grafana.mod.nix diff --git a/modules/services/kanata/module.nix b/modules/services/kanata/kanata.mod.nix similarity index 100% rename from modules/services/kanata/module.nix rename to modules/services/kanata/kanata.mod.nix diff --git a/modules/services/monitoring/loki/module.nix b/modules/services/monitoring/loki/loki.mod.nix similarity index 100% rename from modules/services/monitoring/loki/module.nix rename to modules/services/monitoring/loki/loki.mod.nix diff --git a/modules/services/prometheus/module.nix b/modules/services/prometheus/prometheus.mod.nix similarity index 100% rename from modules/services/prometheus/module.nix rename to modules/services/prometheus/prometheus.mod.nix diff --git a/modules/style/quickshell/quickshell.mod.nix b/modules/style/quickshell/quickshell.mod.nix index 275bbfb..cff3df9 100644 --- a/modules/style/quickshell/quickshell.mod.nix +++ b/modules/style/quickshell/quickshell.mod.nix @@ -1,8 +1,8 @@ { config, - inputs, lib, pkgs, + sources, ... }: let inherit (lib.modules) mkIf; @@ -14,7 +14,7 @@ in { config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ - inputs.quickshell.packages.${pkgs.stdenv.system}.quickshell + (pkgs.callPackage (sources.quickshell + "/default.nix") {}) qt6.qtimageformats qt6.qt5compat qt6.qtmultimedia diff --git a/modules/system/boot/lanzaboote.mod.nix b/modules/system/boot/lanzaboote.mod.nix index 6df8f4a..38797f0 100644 --- a/modules/system/boot/lanzaboote.mod.nix +++ b/modules/system/boot/lanzaboote.mod.nix @@ -1,8 +1,8 @@ { config, - inputs, lib, pkgs, + sources, ... }: let inherit (lib.modules) mkIf; @@ -12,7 +12,7 @@ in { options.modules.system.boot.lanzaboote.enable = mkEnableOption "Lanzaboote"; imports = [ - inputs.lanzaboote.nixosModules.lanzaboote + (sources.lanzaboote + "/nix/modules/lanzaboote.nix") ]; config = mkIf cfg.enable { diff --git a/modules/system/hardware/power.mod.nix b/modules/system/hardware/power.mod.nix index 69a725b..b73dd91 100644 --- a/modules/system/hardware/power.mod.nix +++ b/modules/system/hardware/power.mod.nix @@ -1,6 +1,6 @@ { config, - inputs, + sources, lib, pkgs, ... @@ -8,7 +8,7 @@ inherit (lib.modules) mkDefault; in { imports = [ - inputs.watt.nixosModules.default + # (sources.watt + "/nix/module.nix") ]; config = { environment.systemPackages = builtins.attrValues { @@ -29,182 +29,182 @@ in { hardware.acpilight.enable = false; - services.watt = { - enable = true; - # sample config from https://github.com/NotAShelf/watt#sample-configuration - settings = { - rule = [ - { - cpu = { - energy-performance-preference = "power"; - frequency-mhz-maximum = 2000; - governor = "powersave"; - turbo = false; - }; - "if" = { - is-more-than = 85; - value = "$cpu-temperature"; - }; - priority = 100; - } - { - cpu = { - energy-performance-preference = "power"; - frequency-mhz-maximum = 800; - governor = "powersave"; - turbo = false; - }; - "if" = { - all = [ - "?discharging" - { - is-less-than = 0.3; - value = "%power-supply-charge"; - } - ]; - }; - power = {platform-profile = "low-power";}; - priority = 90; - } - { - cpu = { - energy-performance-preference = "performance"; - governor = "performance"; - turbo = true; - }; - "if" = { - all = [ - { - is-more-than = 0.8; - value = "%cpu-usage"; - } - { - is-less-than = 30; - value = "$cpu-idle-seconds"; - } - { - is-less-than = 75; - value = "$cpu-temperature"; - } - ]; - }; - priority = 80; - } - { - cpu = { - energy-performance-bias = "balance_performance"; - energy-performance-preference = "performance"; - governor = "performance"; - turbo = true; - }; - "if" = { - all = [ - {not = "?discharging";} - { - is-more-than = 0.1; - value = "%cpu-usage"; - } - { - is-less-than = 80; - value = "$cpu-temperature"; - } - ]; - }; - priority = 70; - } - { - cpu = { - energy-performance-preference = "balance_performance"; - governor = "schedutil"; - }; - "if" = { - all = [ - { - is-more-than = 0.4; - value = "%cpu-usage"; - } - { - is-less-than = 0.8; - value = "%cpu-usage"; - } - ]; - }; - priority = 60; - } - { - cpu = { - energy-performance-preference = "power"; - governor = "powersave"; - turbo = false; - }; - "if" = { - all = [ - { - is-less-than = 0.2; - value = "%cpu-usage"; - } - { - is-more-than = 60; - value = "$cpu-idle-seconds"; - } - ]; - }; - priority = 50; - } - { - cpu = { - energy-performance-preference = "power"; - frequency-mhz-maximum = 1600; - governor = "powersave"; - turbo = false; - }; - "if" = { - is-more-than = 300; - value = "$cpu-idle-seconds"; - }; - priority = 40; - } - { - cpu = { - energy-performance-preference = "power"; - frequency-mhz-maximum = 2000; - governor = "powersave"; - turbo = false; - }; - "if" = { - all = [ - "?discharging" - { - is-less-than = 0.5; - value = "%power-supply-charge"; - } - ]; - }; - power = {platform-profile = "low-power";}; - priority = 30; - } - { - cpu = { - energy-performance-bias = "balance_power"; - energy-performance-preference = "power"; - frequency-mhz-maximum = 1800; - frequency-mhz-minimum = 200; - governor = "powersave"; - turbo = false; - }; - "if" = "?discharging"; - priority = 20; - } - { - cpu = { - energy-performance-preference = "balance_performance"; - governor = "schedutil"; - }; - priority = 0; - } - ]; - }; - }; + # services.watt = { + # enable = true; + # # sample config from https://github.com/NotAShelf/watt#sample-configuration + # settings = { + # rule = [ + # { + # cpu = { + # energy-performance-preference = "power"; + # frequency-mhz-maximum = 2000; + # governor = "powersave"; + # turbo = false; + # }; + # "if" = { + # is-more-than = 85; + # value = "$cpu-temperature"; + # }; + # priority = 100; + # } + # { + # cpu = { + # energy-performance-preference = "power"; + # frequency-mhz-maximum = 800; + # governor = "powersave"; + # turbo = false; + # }; + # "if" = { + # all = [ + # "?discharging" + # { + # is-less-than = 0.3; + # value = "%power-supply-charge"; + # } + # ]; + # }; + # power = {platform-profile = "low-power";}; + # priority = 90; + # } + # { + # cpu = { + # energy-performance-preference = "performance"; + # governor = "performance"; + # turbo = true; + # }; + # "if" = { + # all = [ + # { + # is-more-than = 0.8; + # value = "%cpu-usage"; + # } + # { + # is-less-than = 30; + # value = "$cpu-idle-seconds"; + # } + # { + # is-less-than = 75; + # value = "$cpu-temperature"; + # } + # ]; + # }; + # priority = 80; + # } + # { + # cpu = { + # energy-performance-bias = "balance_performance"; + # energy-performance-preference = "performance"; + # governor = "performance"; + # turbo = true; + # }; + # "if" = { + # all = [ + # {not = "?discharging";} + # { + # is-more-than = 0.1; + # value = "%cpu-usage"; + # } + # { + # is-less-than = 80; + # value = "$cpu-temperature"; + # } + # ]; + # }; + # priority = 70; + # } + # { + # cpu = { + # energy-performance-preference = "balance_performance"; + # governor = "schedutil"; + # }; + # "if" = { + # all = [ + # { + # is-more-than = 0.4; + # value = "%cpu-usage"; + # } + # { + # is-less-than = 0.8; + # value = "%cpu-usage"; + # } + # ]; + # }; + # priority = 60; + # } + # { + # cpu = { + # energy-performance-preference = "power"; + # governor = "powersave"; + # turbo = false; + # }; + # "if" = { + # all = [ + # { + # is-less-than = 0.2; + # value = "%cpu-usage"; + # } + # { + # is-more-than = 60; + # value = "$cpu-idle-seconds"; + # } + # ]; + # }; + # priority = 50; + # } + # { + # cpu = { + # energy-performance-preference = "power"; + # frequency-mhz-maximum = 1600; + # governor = "powersave"; + # turbo = false; + # }; + # "if" = { + # is-more-than = 300; + # value = "$cpu-idle-seconds"; + # }; + # priority = 40; + # } + # { + # cpu = { + # energy-performance-preference = "power"; + # frequency-mhz-maximum = 2000; + # governor = "powersave"; + # turbo = false; + # }; + # "if" = { + # all = [ + # "?discharging" + # { + # is-less-than = 0.5; + # value = "%power-supply-charge"; + # } + # ]; + # }; + # power = {platform-profile = "low-power";}; + # priority = 30; + # } + # { + # cpu = { + # energy-performance-bias = "balance_power"; + # energy-performance-preference = "power"; + # frequency-mhz-maximum = 1800; + # frequency-mhz-minimum = 200; + # governor = "powersave"; + # turbo = false; + # }; + # "if" = "?discharging"; + # priority = 20; + # } + # { + # cpu = { + # energy-performance-preference = "balance_performance"; + # governor = "schedutil"; + # }; + # priority = 0; + # } + # ]; + # }; + # }; services = { upower = { enable = true; diff --git a/modules/system/nix/determinate.mod.nix b/modules/system/nix/determinate.mod.nix new file mode 100644 index 0000000..cab9547 --- /dev/null +++ b/modules/system/nix/determinate.mod.nix @@ -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"; + }; + }; + }; + }; + }; +} diff --git a/modules/system/nix/nix.mod.nix b/modules/system/nix/nix.mod.nix index 20a9561..8cc3282 100644 --- a/modules/system/nix/nix.mod.nix +++ b/modules/system/nix/nix.mod.nix @@ -1,7 +1,7 @@ # credits to raf { config, - inputs, + sources, lib, pkgs, ... @@ -9,10 +9,6 @@ inherit (lib.attrsets) mapAttrsToList; inherit (lib.modules) mkForce; in { - imports = [ - inputs.determinate.nixosModules.default - ]; - nix = { # Check that Nix can parse the generated nix.conf. checkConfig = true; @@ -25,9 +21,9 @@ in { # this is taken from sioodmy. # pin the registry to avoid downloading and evaling a new nixpkgs version every time - registry = - lib.mapAttrs (_: v: {flake = v;}) inputs - // {system.flake = inputs.self;}; + # registry = + # lib.mapAttrs (_: v: {flake = v.outPath;}) sources + # // {system.flake = sources.nichts;}; # Add inputs to the system's legacy channels # to make legacy nix commands consistent as well @@ -157,7 +153,7 @@ in { ]; # Determinate nix config # =========================================== - lazy-trees = true; + # lazy-trees = true; # =========================================== }; }; diff --git a/modules/system/nix/nixpkgs.mod.nix b/modules/system/nix/nixpkgs.mod.nix index 847546a..afff4f5 100644 --- a/modules/system/nix/nixpkgs.mod.nix +++ b/modules/system/nix/nixpkgs.mod.nix @@ -1,8 +1,14 @@ # taken from raf -{ +{sources, ...}: { # Global nixpkgs configuration. # This is ignored if nixpkgs.pkgs is set, which should be avoided. nixpkgs = { + flake = { + source = sources.nixpkgs; + setFlakeRegistry = true; + setNixPath = true; + }; + # Configuration reference: # config = { diff --git a/modules/system/os/impermanence.mod.nix b/modules/system/os/impermanence.mod.nix index 8484f52..bc778e7 100644 --- a/modules/system/os/impermanence.mod.nix +++ b/modules/system/os/impermanence.mod.nix @@ -2,6 +2,7 @@ inputs, config, lib, + sources, ... }: let inherit (lib.modules) mkIf mkForce; @@ -10,7 +11,7 @@ cfg = config.modules.system.impermanence; in { imports = [ - inputs.impermanence.nixosModules.impermanence + (sources.impermanence + "/nixos.nix") ]; config = mkIf cfg.enable { users = { diff --git a/npins/default.nix b/npins/default.nix new file mode 100644 index 0000000..46c315b --- /dev/null +++ b/npins/default.nix @@ -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`" +) diff --git a/npins/sources.json b/npins/sources.json new file mode 100644 index 0000000..ff0c8ef --- /dev/null +++ b/npins/sources.json @@ -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 +} diff --git a/packages/nushell/config.nu b/packages/nushell/config.nu index cfc7fb2..738e2e3 100644 --- a/packages/nushell/config.nu +++ b/packages/nushell/config.nu @@ -315,6 +315,10 @@ if not ($env_vars_file | path exists) { | 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. $env.PATH = ($env.PATH | split row (char esep) | prepend '/run/wrappers/bin')