Need help in understanding some auto generated files

Hi, im still pretty new to nix os and i keep all my config files under home/user/.dotfiles. Im trying to build my setup from scratch and haven’t adopted anyone’s config file blindly yet.

So far the file that i created under this dir was

  1. home.nix
  2. flake.nix
    also created links of
  3. hardware-configuration.nix
  4. configuration.nix
    finally auto generated file
  5. flake.lock

but recently i have started seeing a new directory that got generated in the name as result

user@nixos:~/.dotfiles/ > ls -ltr        
total 28
-rw-r--r-- 1 user users 1526 Dec 10 10:27 hardware-configuration.nix
-rw-r--r-- 1 user users  704 Dec 12 23:15 flake.nix
-rw-r--r-- 1 user users 4505 Jan 30 00:40 configuration.nix
-rw-r--r-- 1 user users 1123 Jan 30 00:41 flake.lock
-rw-r--r-- 1 user users 3044 Feb  8 00:20 home.nix
lrwxrwxrwx 1 user users   67 Feb  8 00:25 result -> /nix/store/s3g8qvbkvjj7cazyy5qqv880m2ps2xsq-home-manager-generation
user@nixos:~/.dotfiles/ > ls -ltr result/
total 32
dr-xr-xr-x 2 root root  4096 Jan  1  1970 lib
lrwxrwxrwx 1 root root    61 Jan  1  1970 home-path -> /nix/store/lgk5kxa0wlspbb94fmbcylcyibvylzrd-home-manager-path
lrwxrwxrwx 1 root root    62 Jan  1  1970 home-files -> /nix/store/jk9qvdvys71iss2j26sh033ig0cxq9c0-home-manager-files
-r--r--r-- 1 root root     6 Jan  1  1970 hm-version
dr-xr-xr-x 2 root root  4096 Jan  1  1970 bin
-r-xr-xr-x 1 root root 11856 Jan  1  1970 activate

i looked into certain files to understand what is it doing exactly. And as a noob i don’t want to end up with conclusions based just on speculations. Can i get some help in getting a clear picture of this result dir files, why they are there, what they do exactly on my machine and how did they get generated automatically(i do remember that i haven’t created these)

result is a symlink to the directory in the nix store containing all the outputs of a nix build. If you run nixos-rebuild build, it will create one of your system build.

That directory literally contains the full system. In it are more symlinks that point elsewhere.

If you also run nixos-rebuild switch, the activate script at the root of that directory will be executed, which will turn your system into the one in the directory.

You can delete that symlink if you want, it’s not necessary for anything in particular, you probably just used build instead of boot or switch once without knowing what it does.

1 Like

thanks for the explanation on the result folder @TLATER . As you have mentioned i did nixos-rebuild build but later i gave the command nixos-rebuild switch. And my previous generations seems to boot by default even after giving switch command.

$ sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
  14   2024-02-08 00:32:30   
  15   2024-02-08 00:36:07   (current)

though the list generation points 15 as current, its currently booted into 14.
what should i do inorder to make 15 as default and remove 14 from the generations and boot too.

Weird, are you sure? If you repeatedly press spacebar as the system boots to bring up the systemd-boot menu, do you see the new generations there?

This is how by boot menu looks now(whithout pressing space bar multiple times). once i log in and try to list the generations on the terminal

$ sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
  14   2024-02-08 00:32:30   
  15   2024-02-08 00:36:07   (current)

this is how it show

Also, i just realized one thing. I have recently installed homemanager. But i made change inside the configuration.nix instead of home.nix file. and i guess i gave the command

home-manager switch --flake.

instead of

sudo nixos-rebuild switch --flake .

or may be the other way round. i couldn’t get that from histry too.
please correct me if im giving the wrong command, or this might be the issue of that weird behavior
To be more clear on my current configuration mess and unclear usage of commands which i have did in the past, i have explained it over here