I am trying out nix flakes for my /etc/nixos/configuration.nix, and now I’m unable to do nixos-rebuild switch
without errors.
I get:
╭─hhefesto@Olimpo ~
╰─$ sudo nixos-rebuild switch --flake '/etc/nixos#olimpo'
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
Traceback (most recent call last):
File "/nix/store/6dmc2579q6dmmx0dkv4wc243q89n5mxq-systemd-boot-builder.py", line 256, in <module>
main()
File "/nix/store/6dmc2579q6dmmx0dkv4wc243q89n5mxq-systemd-boot-builder.py", line 223, in main
remove_old_entries(gens)
File "/nix/store/6dmc2579q6dmmx0dkv4wc243q89n5mxq-systemd-boot-builder.py", line 145, in remove_old_entries
known_paths.append(copy_from_profile(*gen, "kernel", True))
File "/nix/store/6dmc2579q6dmmx0dkv4wc243q89n5mxq-systemd-boot-builder.py", line 62, in copy_from_profile
store_file_path = profile_path(profile, generation, name)
File "/nix/store/6dmc2579q6dmmx0dkv4wc243q89n5mxq-systemd-boot-builder.py", line 59, in profile_path
return os.readlink("%s/%s" % (system_dir(profile, generation), name))
FileNotFoundError: [Errno 2] No such file or directory: '/nix/var/nix/profiles/system-6-link/kernel'
warning: error(s) occurred while switching to the new configuration
From /nix/var/nix/profiles/system-1-link
to /nix/var/nix/profiles/system-5-link
the kernel file does exist. From /nix/var/nix/profiles/system-6-link
to /nix/var/nix/profiles/system-20-link
it’s not there (I guess system-6-link was my first configuration with flake).
This is my flake:
{
description = "hhefesto's system configuration";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = inputs@{ self, nixpkgs, ... }:
{
nixosConfigurations.olimpo = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ (import ./configuration.nix) ];
specialArgs = { inherit inputs; };
};
};
}
partially trimed configuration.nix
:
{ config, pkgs, lib, modulesPath, inputs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "olimpo"; # Define your hostname.
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
emacs
git
];
programs.light.enable = true;
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestions.enable = true;
interactiveShellInit = ''
# z - jump around
# source ${pkgs.fetchurl {url = "https://github.com/rupa/z/raw/2ebe419ae18316c5597dd5fb84b5d8595ff1dde9/z.sh"; sha256 = "0ywpgk3ksjq7g30bqbhl9znz3jh6jfg8lxnbdbaiipzgsy41vi10";}}
save_aliases=$(alias -L)
export ZSH=${pkgs.oh-my-zsh}/share/oh-my-zsh
export ZSH_THEME="bira" #"lambda"
plugins=(git sudo colorize extract history postgres)
source $ZSH/oh-my-zsh.sh
eval $save_aliases; unset save_aliases
'';
promptInit = ''
any-nix-shell zsh --info-right | source /dev/stdin
'';
};
networking.firewall.allowedTCPPorts = [ 3000 5432 587 5938 ];
networking.firewall.allowedUDPPorts = [ 5938 ];
services.openssh.enable = true;
services.sshd.enable = true;
services.xserver.enable = true;
services.xserver.layout = "us";
services.xserver.xkbOptions = "ctrl:nocaps";
services.xserver.xkbVariant = "altgr-intl";
services.xserver.windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = haskellPackages:[
haskellPackages.xmonad-contrib
haskellPackages.xmonad-extras
haskellPackages.xmonad
];
};
services.xserver.displayManager = {
defaultSession = "gnome";
gdm.enable = true;
# autoLogin.user = "hhefesto";
};
services.xserver.desktopManager.gnome3.enable = true;
virtualisation.docker.enable = true;
virtualisation.virtualbox.host.enable = true;
users.mutableUsers = false;
users.users.root.initialHashedPassword = "$6$/RvS0Se.iCx$A0eA/8PzgMj.Ms9ohNamfu53c9S.zdG30hEmUHLjmWP0CaXTPVA6QxGIZ6fy.abkjSOTJMAq7fFL6LUBGs4BU0";
users.users.hhefesto.initialHashedPassword = "$6$/RvS0Se.iCx$A0eA/8PzgMj.Ms9ohNamfu53c9S.zdG30hEmUHLjmWP0CaXTPVA6QxGIZ6fy.abkjSOTJMAq7fFL6LUBGs4BU0"; # this may be redundant
users.extraUsers.hhefesto = {
createHome = true;
isNormalUser = true;
home = "/home/hhefesto";
description = "Daniel Herrera";
extraGroups = [ "video" "wheel" "networkmanager" "docker" ];
hashedPassword = "$6$/RvS0Se.iCx$A0eA/8PzgMj.Ms9ohNamfu53c9S.zdG30hEmUHLjmWP0CaXTPVA6QxGIZ6fy.abkjSOTJMAq7fFL6LUBGs4BU0";
shell = pkgs.zsh; #"/run/current-system/sw/bin/bash";
};
# For nix flakes
nix.package = pkgs.nixFlakes;
nix.extraOptions = "experimental-features = nix-command flakes";
nix.allowedUsers = [ "@wheel" "hhefesto" ];
nix.trustedUsers = [ "root" "hhefesto" ];
}
This is the second third day I’ve tried to fix this without any luck. Any guidance is greatly appreciated.
Thank you very much for reading,
Daniel
edit: removed comments and trimmed down some of configuration.nix
. I’m unsure of how much more I can trim it down: suggestions very welcomed.