]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/commitdiff
Flake cleanup and make usable in a system configuration (#316)
authorSandro <sandro.jaeckel@gmail.com>
Sun, 4 Feb 2024 14:41:39 +0000 (15:41 +0100)
committerGitHub <noreply@github.com>
Sun, 4 Feb 2024 14:41:39 +0000 (15:41 +0100)
* Do not rely on the flake registry to resolve nixpkgs

This can cause using the wrong nixpkgs if people have overwritten it
locally

* Misc cleanup

* Migrate off deprecated defaultPackage/defaultApp

* Don't install executable under $out/usr/bin

If the flake is used in a system configuration then now executable gets
linked and appears in PATH

* Update flake.nix

---------

Co-authored-by: b3nj5m1n <47924309+b3nj5m1n@users.noreply.github.com>
flake.lock
flake.nix

index 9514603461f7cc31d52680b4423b69e01e2cecf5..be5b7a895cc8ec358a19ce842a293e2f73c033e5 100644 (file)
@@ -1,12 +1,15 @@
 {
   "nodes": {
     "flake-utils": {
 {
   "nodes": {
     "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
       "locked": {
       "locked": {
-        "lastModified": 1676283394,
-        "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
+        "lastModified": 1694529238,
+        "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
         "owner": "numtide",
         "repo": "flake-utils",
         "owner": "numtide",
         "repo": "flake-utils",
-        "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
+        "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
         "type": "github"
       },
       "original": {
         "type": "github"
       },
       "original": {
     },
     "nixpkgs": {
       "locked": {
     },
     "nixpkgs": {
       "locked": {
-        "lastModified": 1678594102,
-        "narHash": "sha256-OHAHYiMWJFPNxuW/PcOMlSD2tvXnEYC1jxREBADHwwQ=",
+        "lastModified": 1695132891,
+        "narHash": "sha256-cJR9AFHmt816cW/C9necLJyOg/gsnkvEeFAfxgeM1hc=",
         "owner": "NixOS",
         "repo": "nixpkgs",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "796b4a3c1d903c4b9270cd2548fe46f524eeb886",
+        "rev": "8b5ab8341e33322e5b66fb46ce23d724050f6606",
         "type": "github"
       },
       "original": {
         "type": "github"
       },
       "original": {
-        "id": "nixpkgs",
-        "type": "indirect"
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
       }
     },
     "root": {
       }
     },
     "root": {
         "flake-utils": "flake-utils",
         "nixpkgs": "nixpkgs"
       }
         "flake-utils": "flake-utils",
         "nixpkgs": "nixpkgs"
       }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
     }
   },
   "root": "root",
     }
   },
   "root": "root",
index 5a1be2c21cce6fd7a1c971081d85a72352726eba..413dea57e37dfde5cce86eacb6fdf0b3d1782b61 100644 (file)
--- a/flake.nix
+++ b/flake.nix
@@ -1,6 +1,6 @@
 {
   inputs = {
 {
   inputs = {
-    nixpkgs.url = "nixpkgs";
+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
     flake-utils.url = "github:numtide/flake-utils";
   };
   outputs = {
     flake-utils.url = "github:numtide/flake-utils";
   };
   outputs = {
   }:
     flake-utils.lib.eachDefaultSystem (system:
       let
   }:
     flake-utils.lib.eachDefaultSystem (system:
       let
-        runtimeDependencies = with pkgs; [
-          glow
-          jq
-          findutils
-        ];
         overlays = [
           (self: super: {
             xdg-ninja = super.xdg-ninja.overrideAttrs (old: {
         overlays = [
           (self: super: {
             xdg-ninja = super.xdg-ninja.overrideAttrs (old: {
         ];
         pkgs = import nixpkgs { inherit system overlays; };
       in rec {
         ];
         pkgs = import nixpkgs { inherit system overlays; };
       in rec {
-        packages = flake-utils.lib.flattenTree {
+        packages = flake-utils.lib.flattenTree rec {
+          default = xdg-ninja;
           # The shell script and configurations, uses derivation from offical nixpkgs
           # The shell script and configurations, uses derivation from offical nixpkgs
-          xdg-ninja = pkgs.stdenv.mkDerivation rec {
+          xdg-ninja = pkgs.stdenv.mkDerivation {
             pname = "xdg-ninja";
             version = "0.1.0";
 
             pname = "xdg-ninja";
             version = "0.1.0";
 
             installPhase = ''
               runHook preInstall
 
             installPhase = ''
               runHook preInstall
 
-              DESTDIR="$out" PREFIX="/usr" make install
+              DESTDIR="$out" PREFIX= make install
 
 
-              wrapProgram "$out/usr/bin/xdg-ninja" \
-                --prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.glow pkgs.jq ]}"
+              wrapProgram "$out/bin/xdg-ninja" \
+                --prefix PATH : "${pkgs.lib.makeBinPath (with pkgs; [ glow jq findutils ])}"
 
               runHook postInstall
             '';
 
               runHook postInstall
             '';
@@ -50,7 +46,6 @@
           xdgnj-bin = pkgs.stdenvNoCC.mkDerivation {
             name = "xdgnj-bin";
             version = "0.2.0.1-alpha";
           xdgnj-bin = pkgs.stdenvNoCC.mkDerivation {
             name = "xdgnj-bin";
             version = "0.2.0.1-alpha";
-            description = "Pre-built binary of the xdgnj tool for creating and editing configuration files for xdg-ninja.";
             src = pkgs.fetchurl {
               url = "https://github.com/b3nj5m1n/xdg-ninja/releases/download/v0.2.0.1/xdgnj";
               sha256 = "y1BSqKQWbhCyg2sRgMsv8ivmylSUJj6XZ8o+/2oT5ns=";
             src = pkgs.fetchurl {
               url = "https://github.com/b3nj5m1n/xdg-ninja/releases/download/v0.2.0.1/xdgnj";
               sha256 = "y1BSqKQWbhCyg2sRgMsv8ivmylSUJj6XZ8o+/2oT5ns=";
               mkdir -p "$out/bin"
               install -Dm755 $src "$out/bin/xdgnj"
             '';
               mkdir -p "$out/bin"
               install -Dm755 $src "$out/bin/xdgnj"
             '';
+            meta.description = "Pre-built binary of the xdgnj tool for creating and editing configuration files for xdg-ninja.";
           };
         };
           };
         };
-        defaultPackage = packages.xdg-ninja;
-        apps = {
-          xdg-ninja = flake-utils.lib.mkApp { drv = packages.xdg-ninja; exePath = "/usr/bin/xdg-ninja"; };
+        apps = rec {
+          default = xdg-ninja;
+          xdg-ninja = flake-utils.lib.mkApp { drv = packages.xdg-ninja; exePath = "/bin/xdg-ninja"; };
           xdgnj-bin = flake-utils.lib.mkApp { drv = packages.xdgnj-bin; exePath = "/bin/xdgnj"; };
         };
           xdgnj-bin = flake-utils.lib.mkApp { drv = packages.xdgnj-bin; exePath = "/bin/xdgnj"; };
         };
-        defaultApp = apps.xdg-ninja;
       }
     );
 }
       }
     );
 }