From c5a4325596fbb71e75f4f945db5ab70881b43357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 31 Oct 2022 15:55:40 +0100 Subject: pkgs: add dev --- flake.lock | 38 +++++++++++++++++++------------------- nixos/modules/develop.nix | 1 + pkgs/default.nix | 3 +++ pkgs/dev/default.nix | 29 +++++++++++++++++++++++++++++ pkgs/dev/dev.sh | 15 +++++++++++++++ 5 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 pkgs/dev/default.nix create mode 100755 pkgs/dev/dev.sh diff --git a/flake.lock b/flake.lock index ab1b61a..688d532 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", "type": "github" }, "original": { @@ -79,11 +79,11 @@ "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1666244640, - "narHash": "sha256-BKbf12IZZYrCJQk12MTdj7u9DLyfWTIomKad5QMmgxw=", + "lastModified": 1667213331, + "narHash": "sha256-M8w6ETCl2Iwugb1xZBZp9Is2zD9tj18EARtrADNcAQ4=", "owner": "NixOS", "repo": "nix", - "rev": "b3d2a05c59266688aa904d5fb326394cbb7e9e90", + "rev": "90ed041677cb55d432a1bea0749af2a59f3ff6bb", "type": "github" }, "original": { @@ -93,11 +93,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1665987993, - "narHash": "sha256-MvlaIYTRiqefG4dzI5p6vVCfl+9V8A1cPniUjcn6Ngc=", + "lastModified": 1667221253, + "narHash": "sha256-PGGT7D/qmi1E8D1Z32SLrzq7PJO5CajD64GfCCdslk0=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "0e6593630071440eb89cd97a52921497482b22c6", + "rev": "d5bacd34f54328f31bef9237098fdeaad83074be", "type": "github" }, "original": { @@ -139,11 +139,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1666570118, - "narHash": "sha256-MTXmIYowHM1wyIYyqPdBLia5SjGnxETv0YkIbDsbkx4=", + "lastModified": 1667055375, + "narHash": "sha256-xfSTHYxuKRiqF4dcuAFdti1OUvrC2lHpQqCHWUK5/JA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1e684b371cf05300bc2b432f958f285855bac8fb", + "rev": "7f9be6a505a31f88499c5d20d11f98accf5ae6ba", "type": "github" }, "original": { @@ -250,11 +250,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1665670695, - "narHash": "sha256-ggnEnAC28aLWrA+nynLDgWYJv/sUy8RYYQekfeYigkY=", + "lastModified": 1667207766, + "narHash": "sha256-iD6csuGtnVjP3aOgqrjh5wOge0VK2hywAWLRXe0PjKk=", "ref": "refs/heads/master", - "rev": "9eb1eabfb13c3a88b0a6fd4832bd76c4ba5a1159", - "revCount": 80, + "rev": "d93457ad3097ed6f78e6c8b4862f98b81ede5205", + "revCount": 81, "type": "git", "url": "https://git.cynerd.cz/shellrc" }, @@ -303,11 +303,11 @@ }, "vpsadminos": { "locked": { - "lastModified": 1666486675, - "narHash": "sha256-NM3n3XS0fk4AV1HMquAc+vTKoSbk3NYljby0iz1z01k=", + "lastModified": 1667047944, + "narHash": "sha256-1DexHqwWYccjtaWmndbsEbCk5fg8gFrCaUbjSmVFGso=", "owner": "vpsfreecz", "repo": "vpsadminos", - "rev": "fec963674b69bd8e4f6d772d9965e1f2a4928446", + "rev": "8cd4c63c8e382b3e6bc8cba39a7d806ce6507a2a", "type": "github" }, "original": { diff --git a/nixos/modules/develop.nix b/nixos/modules/develop.nix index b03bb8d..335f2a3 100644 --- a/nixos/modules/develop.nix +++ b/nixos/modules/develop.nix @@ -27,6 +27,7 @@ in { parted # Nix + dev nix-prefetch-git nix-prefetch-github nix-prefetch-scripts nix-universal-prefetch rnix-lsp diff --git a/pkgs/default.nix b/pkgs/default.nix index 7c1350b..d2d7828 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -6,6 +6,9 @@ let personalpkgs = rec { luks-hw-password = callPackage ./luks-hw-password { }; + dev = callPackage ./dev { + devShells = self.devShells.${nixpkgs.system}; + }; delft-icon-theme = callPackage ./theme/delft-icon-theme.nix { }; background-lnxpcs = callPackage ./theme/background-lnxpcs.nix { }; diff --git a/pkgs/dev/default.nix b/pkgs/dev/default.nix new file mode 100644 index 0000000..9238f4d --- /dev/null +++ b/pkgs/dev/default.nix @@ -0,0 +1,29 @@ +{ lib, stdenvNoCC +, makeShellWrapper, bash, nix +, devShells +}: + +with lib; + +let + + shells = concatStringsSep ":" (mapAttrsToList (n: v: "${n}=${v}") devShells); + +in stdenvNoCC.mkDerivation rec { + name = "personal-devshells"; + src = ./.; + + nativeBuildInputs = [ makeShellWrapper ]; + installPhase = '' + makeShellWrapper ${./dev.sh} $out/bin/dev \ + --prefix PATH : ${lib.makeBinPath [ bash nix ]} \ + --set DEV_SHELLS "${shells}" \ + --set DEV_FLAKE "${../..}" + ''; + + meta = with lib; { + description = "Console version of Stardict program"; + homepage = "https://dushistov.github.io/sdcv/"; + license = licenses.gpl2; + }; +} diff --git a/pkgs/dev/dev.sh b/pkgs/dev/dev.sh new file mode 100755 index 0000000..f88224a --- /dev/null +++ b/pkgs/dev/dev.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -eu + +target="$1" +shift + +known_shells="$(tr ':' '\n' <<<"${DEV_SHELLS:-}")" +while IFS='=' read name val; do + if [ "$target" == "$name" ]; then + target="$DEV_FLAKE#$name" + break + fi +done <<<"$known_shells" + +exec nix develop "$target" -c zsh "$@" -- cgit v1.2.3