From 44aec28df76a8a353a3b4bdb81a1159b6548fe75 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 27 Jun 2025 20:14:46 +0200 Subject: [PATCH] System: Install nps to search nixpkgs from a terminal environment --- flake.lock | 180 ++++++++++++++++++++++++++------------------- flake.nix | 18 ++++- system/default.nix | 31 ++++++++ 3 files changed, 151 insertions(+), 78 deletions(-) diff --git a/flake.lock b/flake.lock index 0f514afc..b3163744 100644 --- a/flake.lock +++ b/flake.lock @@ -3,7 +3,9 @@ "ags": { "inputs": { "astal": "astal", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1744557573, @@ -107,7 +109,7 @@ }, "devshell": { "inputs": { - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" }, "locked": { "lastModified": 1741473158, @@ -125,7 +127,9 @@ }, "emacs-overlay": { "inputs": { - "nixpkgs": "nixpkgs_3", + "nixpkgs": [ + "nixpkgs" + ], "nixpkgs-stable": "nixpkgs-stable" }, "locked": { @@ -157,6 +161,20 @@ "type": "github" } }, + "flake-compat_2": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -217,6 +235,21 @@ "type": "github" } }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "hardware": { "locked": { "lastModified": 1748942041, @@ -302,11 +335,31 @@ "type": "github" } }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1733346208, + "narHash": "sha256-a4WZp1xQkrnA4BbnKrzJNr+dYoQr5Xneh2syJoddFyE=", + "owner": "nix-community", + "repo": "naersk", + "rev": "378614f37a6bee5a3f2ef4f825a73d948d3ae921", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, "nix-alien": { "inputs": { "flake-compat": "flake-compat", "nix-index-database": "nix-index-database", - "nixpkgs": "nixpkgs_4" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1747908601, @@ -361,16 +414,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743583204, - "narHash": "sha256-F7n4+KOIfWrwoQjXrL2wD9RhFYLs2/GGe/MQY1sSdlE=", - "owner": "nixos", + "lastModified": 1722073938, + "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "2c8d3f48d33929642c1c12cd243df4cc7d2ce434", + "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -393,82 +446,31 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1722073938, - "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", - "owner": "NixOS", + "lastModified": 1748693115, + "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", + "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", + "owner": "nixos", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_3": { "locked": { - "lastModified": 1748693115, - "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", - "type": "github" + "lastModified": 1734323986, + "narHash": "sha256-m/lh6hYMIWDYHCAsn81CDAiXoT3gmxXI9J987W5tZrE=", + "path": "/nix/store/wj2qla569hnxwqfc26imv5hqbxc1rc27-source", + "rev": "394571358ce82dff7411395829aa6a3aad45b907", + "type": "path" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { - "locked": { - "lastModified": 1747179050, - "narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_5": { - "locked": { - "lastModified": 1748693115, - "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_6": { - "locked": { - "lastModified": 1748693115, - "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "id": "nixpkgs", + "type": "indirect" } }, "nixvim": { @@ -494,10 +496,35 @@ "type": "github" } }, + "nps": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "naersk": "naersk", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738483270, + "narHash": "sha256-q/PkigsNAI7MCmeDFBMGuZJFXVL95pQCNOVhNvBH9dc=", + "owner": "OleMussmann", + "repo": "nps", + "rev": "2d005f22a52a0bda19d1afd8736ad5bfcb1d38cf", + "type": "github" + }, + "original": { + "owner": "OleMussmann", + "repo": "nps", + "type": "github" + } + }, "nur": { "inputs": { "flake-parts": "flake-parts_2", - "nixpkgs": "nixpkgs_6", + "nixpkgs": [ + "nixpkgs" + ], "treefmt-nix": "treefmt-nix" }, "locked": { @@ -547,8 +574,9 @@ "hyprpanel": "hyprpanel", "nix-alien": "nix-alien", "nix-flatpak": "nix-flatpak", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_2", "nixvim": "nixvim", + "nps": "nps", "nur": "nur" } }, diff --git a/flake.nix b/flake.nix index 9239df7b..c04304fc 100644 --- a/flake.nix +++ b/flake.nix @@ -16,20 +16,34 @@ # NeoVim <3 nixvim.url = "github:nix-community/nixvim"; nixvim.inputs.nixpkgs.follows = "nixpkgs"; - # blink-cmp.url = "github:saghen/blink.cmp"; # Nix User Repository (e.g. Firefox addons) nur.url = "github:nix-community/NUR"; + nur.inputs.nixpkgs.follows = "nixpkgs"; # Ags for widgets (this was a terrible idea) ags.url = "github:Aylur/ags"; + ags.inputs.nixpkgs.follows = "nixpkgs"; + + # Hyprpanel hyprpanel.url = "github:jas-singhfsu/hyprpanel"; hyprpanel.inputs.nixpkgs.follows = "nixpkgs"; - # Other + # Nix Package Search - nps + nps.url = "github:OleMussmann/nps"; + nps.inputs.nixpkgs.follows = "nixpkgs"; + + # Declarative Flatpak nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest"; + nix-flatpak.inputs.nixpkgs.follows = "nixpkgs"; + + # Creates an environment containing required libraries for an executable nix-alien.url = "github:thiagokokada/nix-alien"; + nix-alien.inputs.nixpkgs.follows = "nixpkgs"; + + # Emacs nightly emacs-overlay.url = "github:nix-community/emacs-overlay"; + emacs-overlay.inputs.nixpkgs.follows = "nixpkgs"; # TODO: Move away from devshell, as it breaks e.g. C++/Rust library propagation # and doesn't provide any benefits for me diff --git a/system/default.nix b/system/default.nix index baca881d..c6ca0f12 100644 --- a/system/default.nix +++ b/system/default.nix @@ -9,6 +9,7 @@ config, pkgs, system, + username, ... }: with mylib.networking; { @@ -404,6 +405,9 @@ with mylib.networking; { # Start dynamically linked executable using "nix-alien-ld -- " inputs.nix-alien.packages.${system}.nix-alien + # Search nixpkgs + inputs.nps.packages.${system}.default + # egl-wayland ]; @@ -538,6 +542,33 @@ with mylib.networking; { libvirtd.enable = true; }; + systemd = { + # TODO: Technically this should be a user service if it runs as ${username}? + timers."refresh-nps-cache" = { + wantedBy = ["timers.target"]; + timerConfig = { + OnCalendar = "weekly"; # or however often you'd like + Persistent = true; + Unit = "refresh-nps-cache.service"; + }; + }; + + services."refresh-nps-cache" = { + # Make sure `nix` and `nix-env` are findable by systemd.services. + path = ["/run/current-system/sw/"]; + serviceConfig = { + Type = "oneshot"; + User = "${username}"; # ⚠️ replace with your "username" or "${user}", if it's defined + }; + script = '' + set -eu + echo "Start refreshing nps cache..." + ${inputs.nps.packages.${system}.default}/bin/nps -dddd -e -r + echo "... finished nps cache with exit code $?." + ''; + }; + }; + # The current system was installed on 22.05, do not change. # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions