Update utilities and package repository list
parent
9d3309c6be
commit
c57f3ecfab
@ -0,0 +1,7 @@
|
|||||||
|
{ stdenv, pkgs, ... }:
|
||||||
|
{ path, storeHash, ... }:
|
||||||
|
let
|
||||||
|
derivationName = baseNameOf path;
|
||||||
|
storePath = "/nix/store/${storeHash}-${derivationName}";
|
||||||
|
in
|
||||||
|
if builtins.pathExists storePath then storePath else path
|
@ -0,0 +1,37 @@
|
|||||||
|
# Source: http://chriswarbo.net/projects/nixos/useful_hacks.html
|
||||||
|
|
||||||
|
{ args, name }:
|
||||||
|
let
|
||||||
|
nixpkgs = import <nixpkgs> {};
|
||||||
|
lib = nixpkgs.lib;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
# Store each arg in a separate variable, named numerically
|
||||||
|
env = with lib.foldl' (result: arg: {
|
||||||
|
# Increment the count, for the next arg (if any)
|
||||||
|
count = result.count + 1;
|
||||||
|
|
||||||
|
# Append a variable to the environment for this arg
|
||||||
|
vars = result.vars // {
|
||||||
|
"${name}${toString result.count}" = arg;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
# Start with variable 1 in an empty environment
|
||||||
|
{ count = 1; vars = {}; }
|
||||||
|
args;
|
||||||
|
vars;
|
||||||
|
|
||||||
|
code = ''
|
||||||
|
### Auto-generated by nixListToBashArray
|
||||||
|
${name}=()
|
||||||
|
|
||||||
|
for N in $(seq 1 "${toString (lib.length args)}")
|
||||||
|
do
|
||||||
|
# Use a "variable variable" to look up "$name$N" as a variable name
|
||||||
|
NIXLISTTOBASHARRAYTEMP="${name}$N"
|
||||||
|
${name}=("''${${name}[@]}" "''${!NIXLISTTOBASHARRAYTEMP}")
|
||||||
|
unset NIXLISTTOBASHARRAYTEMP
|
||||||
|
done
|
||||||
|
### End of auto-generated code
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue