From a2209c4f8e6541fb7b07a67bc821d1f13b176195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Montero?= Date: Mon, 28 Mar 2022 23:34:10 -0600 Subject: [PATCH] =?UTF-8?q?crea=20shenvs,=20a=C3=B1ade=20infrastructura=20?= =?UTF-8?q?para=20paquetes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 2 ++ home/zshrc.nix | 18 ++++++++++++++++-- pkgs/default.nix | 32 ++++++++++++++++++++++++++++++++ result | 1 - shenvs/armasm.nix | 5 +++++ 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 pkgs/default.nix delete mode 120000 result create mode 100644 shenvs/armasm.nix diff --git a/flake.nix b/flake.nix index 0b5d61a..d38391f 100644 --- a/flake.nix +++ b/flake.nix @@ -23,5 +23,7 @@ homeDirectory = "/home/fabian"; stateVersion = "21.11"; }; + + packages.x86_64-linux = import ./pkgs nixpkgs.legacyPackages.x86_64-linux; }; } diff --git a/home/zshrc.nix b/home/zshrc.nix index 68522c9..7d5b516 100644 --- a/home/zshrc.nix +++ b/home/zshrc.nix @@ -76,7 +76,6 @@ alias x='killall --ignore-case --user=$(whoami) --interactive' alias sc='${maim}/bin/maim -s -u | xclip -selection clipboard -t image/png -i' alias tree='tree -CF' - alias spawn="xdg-open" alias lock="betterlockscreen -l" alias nightmode="${redshift}/bin/redshift -P -O 1000" alias lightmode="${redshift}/bin/redshift -P -O 6500" @@ -85,7 +84,22 @@ bindkey ";5D" backward-word bindkey ";5C" forward-word bindkey "\e[3~" delete-char - + + + function shenv() { + nix shell 'system#shenvs.'"$1" + } + + function spawn () { + if [ ! -x "$(command -v $1)" ] + then + echo "spawn: no such program: $1" >&2 + return 1 + fi + $@ > /dev/null 0>&1 2>&1 & + disown + } + autoload -Uz up-line-or-beginning-search zle -N up-line-or-beginning-search autoload -Uz down-line-or-beginning-search diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..e477dd4 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,32 @@ +pkgs: +with pkgs.lib; let + inherit (pkgs) buildEnv callPackage writeTextDir; + + importAll = { root, exclude ? [] }: + + # adapted from http://chriswarbo.net/projects/nixos/useful_hacks.html + let + basename = removeSuffix ".nix"; + + isMatch = name: type: (hasSuffix ".nix" name || type == "directory") + && ! elem name (map basename exclude); + + entry = name: _: { + name = basename name; + value = import (root + "/${name}"); + }; + in + mapAttrs' entry (filterAttrs isMatch (readDir root)) + +in { + shenvs = let + build = name: { paths, enter ? null }: buildEnv { + name = "shenv-${name}"; + paths = (optional (enter != null) (writeTextDir "lib/shenv/enter" enter)) + ++ paths; + }; + in mapAttrs (name: shenv: build name (shenv pkgs)) (importAll { + root = ../shenvs; + exclude = [ "config" ]; + }); +} diff --git a/result b/result deleted file mode 120000 index 4ba7032..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/8by51srkm9s1rfiqlsp4n6fznm7bjzqb-home-manager-generation \ No newline at end of file diff --git a/shenvs/armasm.nix b/shenvs/armasm.nix new file mode 100644 index 0000000..a73b03f --- /dev/null +++ b/shenvs/armasm.nix @@ -0,0 +1,5 @@ +pkgs: { + paths = with pkgs; [ + gcc-arm-embedded + ]; +}