Skip to content

Commit

Permalink
Flake cleanup and make usable in a system configuration (#316)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
SuperSandro2000 and b3nj5m1n authored Feb 4, 2024
1 parent a74fefd commit 7c7a320
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
36 changes: 28 additions & 8 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 11 additions & 16 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
Expand All @@ -10,11 +10,6 @@
}:
flake-utils.lib.eachDefaultSystem (system:
let
runtimeDependencies = with pkgs; [
glow
jq
findutils
];
overlays = [
(self: super: {
xdg-ninja = super.xdg-ninja.overrideAttrs (old: {
Expand All @@ -25,9 +20,10 @@
];
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
xdg-ninja = pkgs.stdenv.mkDerivation rec {
xdg-ninja = pkgs.stdenv.mkDerivation {
pname = "xdg-ninja";
version = "0.1.0";

Expand All @@ -38,10 +34,10 @@
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
'';
Expand All @@ -50,7 +46,6 @@
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=";
Expand All @@ -60,14 +55,14 @@
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"; };
};
defaultApp = apps.xdg-ninja;
}
);
}

0 comments on commit 7c7a320

Please sign in to comment.