Last active
May 25, 2024 01:14
-
-
Save hbjydev/566df3e92a35fcd89c4d6aa611cd0a71 to your computer and use it in GitHub Desktop.
Flake for including ipcalc Perl script, its license file (as you should be doing) and the man page for it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; | |
outputs = inputs@{ flake-parts, ... }: | |
flake-parts.lib.mkFlake { inherit inputs; } { | |
systems = inputs.nixpkgs.lib.systems.flakeExposed; | |
perSystem = { pkgs, ... }: { | |
packages.default = pkgs.runCommand "ipcalc" { | |
src = pkgs.fetchFromGitHub { | |
owner = "kjokjo"; | |
repo = "ipcalc"; | |
rev = "0.51"; | |
sha256 = "sha256-260GJ0UwEdXFaINa0o8Od/nhyReNyXL8GrfKncx63jI="; | |
}; | |
} '' | |
mkdir -p $out/bin $out/share/man $out/share/doc/ipcalc | |
# Documentation | |
cp $src/ipcalc.1 $out/share/man/ipcalc.1 | |
# This seems like the correct place: | |
# https://discourse.nixos.org/t/collision-between-2-license-txt-from-2-different-packages/22071/5 | |
cp $src/license $out/share/doc/ipcalc/LICENSE.txt | |
# Hotpatch for Perl shebang | |
cp $src/ipcalc ./ipcalc | |
sed -i 's|#!/usr/bin/perl|#!${pkgs.perl}/bin/perl|' ./ipcalc | |
# Store ipcalc executable in output | |
cp ./ipcalc $out/bin/ipcalc | |
chmod +x $out/bin/ipcalc | |
''; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To build this, put it in a folder somewhere (or preferably a GitHub repo) and run
nix build .
against it. Inresult
, there'll be two directories:bin
(which hasipcalc
in it)share
(which has the man pages and license files)To run it, just do
result/bin/ipcalc
.