nix flake lock --update-input <input> --commit-lock-file
updates single input.
nix flake update --update-input
in
2.19repl-flake
now a part of flake
.flake#.attr
- preceding dot means not to look for
attribute in default locations like packages
.fetch-tree
experimental feature in nix/builtins.nix flake update
supports --update-input
but without flags, taking on the role of nix flake lock
.
Example: nix flake update nixpkgs --flake /etc/flake
.
--update-input
consequently was removed.nix store add
- add file or dir to store and print its
path.See config
Options. Most important options:
wants
vs requires
- first create
dependencies, but in the first case dependency is weak and referrer
won't be affected by a referenced exiting.wantedBy
- makes service runnable.script
- what to do.environment
- drop your env here.serviceConfig
User
- who to run as.Type
- type.
dbus
for dbus dependency, waits for unit to listen on a
bus.simple
- simplest, does least checks.exec
- like simple, but makes little more checks.
Preferrable for longer services without dbus or notify interface.forking
- discouraged.oneshot
- default waits for child to
exit, i.e. the most demanding.RootDirectory
- dir to chroot into. e.g.
/run/myService
.*Directory
- sets pwd, env, adds dependencies on
mounts.
WorkingDirectory
- pwd, i.e. 'cd into'.Runtime
, State
, Cache
,
Logs
, Configuration
- set corresponding env
vars and create dirs under some special paths.serviceConfig.DynamicUser = true
to not
create a user system user, saving lines in
/etc/passwd
.[ 'NetworkManager-wait-online.service' ];
wants = [ 'NetworkManager-wait-online.service' ]; after =
Source. Options. Important options:
serviceConfig.OnCalendar
- when. Kinda like chrone's
format but different."hello-world" = {
systemd.timers.wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5m";
OnUnitActiveSec = "5m";
Unit = "hello-world.service";
};
};
"hello-world" = {
systemd.services.script = ''
set -eu
${pkgs.coreutils}/bin/echo "Hello World"
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
systemctl list-timers
- list active timers and their
current state,systemctl start hello-world
- manually run a service
once for testing purposes.There are a couple installers and you can build your own. To create
an installer provide a configuration through a flake or a nix file,
which has some module from ${modulesPath}/installer/
as
import. E.g.
${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix
- the one you would most commonly use. Example configuration:
{
nixosConfigurations.installer = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
({ pkgs, modulesPath, lib, ... }: {
imports = [
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
];
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
users.users.nixos.openssh.authorizedKeys.keyFiles = [ ./ssh/mykey ];
})
./modules/default/tools.nix
];
};
}
Building configurations can be done with
nixos-generate --flake .#installer --format iso -o result
from nixos-generators
. Beware that the process is quite
slow due to squashfs
generation and can take around 6
minutes. Try out your installer before flashing with
nixos-rebuild build-vm --flake .#installer
. Flash resulting
iso with
dd if=result/iso/nixos-smth.iso of=/dev/disk/by-id/usb-ID status=progress && sync
.