summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-11-25 20:17:27 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-11-25 22:29:23 +0100
commitcd4de50188af8836b8450c15d5b60332e1f2174b (patch)
tree891a8e223d97cf0166c26480c13aed53072092d8
parente943f3a8c967d95cb9d57367a57db78e79972d74 (diff)
downloadvtcol-cd4de50188af8836b8450c15d5b60332e1f2174b.tar.gz
misc: add nix derivation
-rw-r--r--.gitignore2
-rw-r--r--Makefile18
-rw-r--r--misc/nixos/pkgs/os-specific/linux/vtcol/default.nix57
3 files changed, 76 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index ae0df3a..88c4ac6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,8 @@ todo
# cargo junk
Cargo.lock
+misc/nixos/pkgs/os-specific/linux/vtcol/cargo-lock.patch
# manpage
doc/vtcol.1.gz
+
diff --git a/Makefile b/Makefile
index a8db336..50dd1b2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,10 @@ lib-src = src/lib.rs
src = $(bin-src) $(lib-src)
meta = Cargo.toml
rustdoc-entry = target/doc/vtcol/index.html
+cargo-lock = Cargo.lock
+cargo-lock-patch= misc/nixos/pkgs/os-specific/linux/vtcol/cargo-lock.patch
-all: bin lib doc
+all: bin lib doc nix
check: $(src)
cargo test
@@ -23,6 +25,18 @@ man: $(manpage)
rustdoc: $(rustdoc-entry)
+nix: lockpatch
+
+lockpatch: $(cargo-lock-patch)
+
+$(cargo-lock-patch): $(meta)
+ rm -f -- $(cargo-lock)
+ cargo update
+ cargo generate-lockfile
+ mkdir -p tmp
+ mv -f -- $(cargo-lock) tmp/
+ diff -u /dev/null tmp/$(cargo-lock) >$(cargo-lock-patch) ; :
+
$(lib): $(lib-src) $(meta)
cargo build --release
@@ -37,6 +51,8 @@ $(rustdoc-entry): $(src) $(meta)
clean:
rm -f -- $(manpage)
+ rm -f -- $(cargo-lock)
rm -rf -- $(cargo-target)
+ rm -rf -- tmp
.PHONY: clean check
diff --git a/misc/nixos/pkgs/os-specific/linux/vtcol/default.nix b/misc/nixos/pkgs/os-specific/linux/vtcol/default.nix
new file mode 100644
index 0000000..dec074b
--- /dev/null
+++ b/misc/nixos/pkgs/os-specific/linux/vtcol/default.nix
@@ -0,0 +1,57 @@
+{ lib, stdenv
+, cpio
+, docutils
+, rust
+, installShellFiles
+, fetchFromGitLab
+, rustPlatform
+}:
+
+rustPlatform.buildRustPackage rec {
+ pname = "vtcol";
+ version = "0.42.5";
+
+ src = fetchFromGitLab {
+ domain = "gitlab.com";
+ owner = "phgsng";
+ repo = pname;
+ rev = "d6e8a37767644b50001e14ebbab594e799a94db7";
+ sha256 = "sha256-fHWxiuCFO+N+ubPCS/Is64V2pLzh7xozDcRo7pQLMBg=";
+ };
+
+ cargoSha256 = "sha256-NSwn3vavrsPr+qn6oQY6kO5d9TKrxwcnqO7a3qpBphs==";
+
+ nativeBuildInputs = [ docutils cpio installShellFiles ];
+
+ buildFeatures = [ "vtcol-bin" ];
+
+ cargoPatches = [ ./cargo-lock.patch ];
+
+ target = rust.toRustTargetSpec stdenv.hostPlatform;
+
+ # building the manpage requires docutils/rst2man
+ postInstall = ''
+ echo "create and install manpage"
+ make man
+ installManPage doc/vtcol.1.gz
+
+ echo "create cpio archive for initrd"
+ binout="target/${target}/release/${pname}"
+ ls "$binout"
+ mkdir -p -- tmp/usr/bin
+ ls
+ ls tmp
+ cp -f -- "$binout" tmp/usr/bin
+ pushd tmp
+ <<<usr/bin/${pname} cpio -ov -H ustar >${pname}.cpio
+
+ install -D -m644 ${pname}.cpio $out/share/vtcol/${pname}.cpio
+ '';
+
+ meta = with lib; {
+ description = "Color schemes for the Linux console";
+ homepage = "https://gitlab.com/phgsng/vtcol";
+ license = licenses.gpl3;
+ mainProgram = "vtcol";
+ };
+}