$derivation/bin
gets linked into PATH
only when explicitely installing it. If, e.g., sieve-filter
is only in /nix/store
because something else dependet on dovecot_pigeonhole
, it won't be in PATH
.
$ nix repl
nix-repl> let pkgs = import <nixos> {}; in "${pkgs.openssh}"
"/nix/store/xig1gasyh9m5fvgk676ab2qa9hbwgcjk-openssh-7.5p1"
/etc/nixos/something.nix:
{ pkgs, ... }:
{
environment.systemPackages = [ (pkgs.writeShellScriptBin "hello-i-am-a-custom-script" ''
set -e
'') ];
}
systemd service
{ config, pkgs, lib, ... }:
{
systemd.services.thermonitor = {
description = "Hello I am your friendly neighborhood daemon";
serviceConfig = {
ExecStart = "/home/youruser/thermonitor.py";
User = "youruser";
Group = "users";
WorkingDirectory = "/home/youruser";
};
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
path = [ pkgs.python3 pkgs.moreutils pkgs.netcat ];
};
}
path = [ pkgs.bash ];
sudo nixos-rebuild switch --rollback
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
Siehe: List-generations and rollback to any configuration · Issue #24374
nix-env -f "<nixpkgs>" -qaP -A haskellPackages
nixos-option <option>
runCommand "name" { buildInputs = [ foo ]; }; ''some bash code'';
pkgs.runCommand "configtest" { buildInputs = [rsnapshot]; }; ''rsnapshot configtest'';
For this to happen after generating the config, you have to be clever with referencing:
You want nix to first build the config and then run runCommand
afterwards.
Since the config needs to be copied into the directory where runCommand
runs, this works in this case.
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p haskellPackages.ghc haskellPackages.HTTP
import Network.HTTP
main = do
resp <- Network.HTTP.simpleHTTP (getRequest "http://nixos.org/")
body <- getResponseBody resp
print (take 100 body)
See nix-script