Closed sgraf812 closed 6 years ago
No, that definitely is not intended. Which output do you get if you run the following command?
ls --sort=time -l /nix/var/nix/gcroots/per-user/$(whoami) /nix/var/nix/profiles/per-user/$(whoami)/home-manager*
lrwxrwxrwx 1 sgraf mitarbeiter 20 Jul 9 18:28 /nix/var/nix/profiles/per-user/sgraf/home-manager -> home-manager-71-link
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jul 9 18:28 /nix/var/nix/profiles/per-user/sgraf/home-manager-71-link -> /nix/store/parjmqbsv6vy31vv9rnabbzzx25wy9lx-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jul 2 09:39 /nix/var/nix/profiles/per-user/sgraf/home-manager-70-link -> /nix/store/kvkg26r7nch52a8h2lssmn52zlrdg7j4-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 29 13:53 /nix/var/nix/profiles/per-user/sgraf/home-manager-69-link -> /nix/store/fkwnxy94xm6dhg2hr7gga6s3zlfkw91x-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 29 12:55 /nix/var/nix/profiles/per-user/sgraf/home-manager-68-link -> /nix/store/51j8capv6kjm8zcmp18pwlx3j8by0nhi-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 28 17:57 /nix/var/nix/profiles/per-user/sgraf/home-manager-67-link -> /nix/store/43mw3145ws673431x2rvxxv8fwk5yvkg-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 26 12:28 /nix/var/nix/profiles/per-user/sgraf/home-manager-66-link -> /nix/store/9q7kl5bf4dhcm0k52nvyf3m67jv3a4cz-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 25 18:28 /nix/var/nix/profiles/per-user/sgraf/home-manager-65-link -> /nix/store/s215z24gksv5s4p6mgyjrzjwb2g9ldna-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 22 23:57 /nix/var/nix/profiles/per-user/sgraf/home-manager-64-link -> /nix/store/l53w831szj64iizja15mjdx6prswx1kf-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 19 13:05 /nix/var/nix/profiles/per-user/sgraf/home-manager-63-link -> /nix/store/cyhwfm9s7krgzxynhgspnpdd6s3ksrbg-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 18 18:34 /nix/var/nix/profiles/per-user/sgraf/home-manager-62-link -> /nix/store/2rzv051dhnihz7sndzjnr3f9cnv2jxlh-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 18 17:19 /nix/var/nix/profiles/per-user/sgraf/home-manager-61-link -> /nix/store/h15i1ggg9qbjyw3giv8dmfqfzafpc46j-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 12 13:16 /nix/var/nix/profiles/per-user/sgraf/home-manager-60-link -> /nix/store/85naysylk580mja38axqcgkzcdm3j5gq-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 11 10:16 /nix/var/nix/profiles/per-user/sgraf/home-manager-59-link -> /nix/store/drg8dvmzdva2abdkrx48q889hzrw8kk7-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 4 17:24 /nix/var/nix/profiles/per-user/sgraf/home-manager-58-link -> /nix/store/jwynkyh68fnkcjwai24xbd2m64akklfd-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 4 17:23 /nix/var/nix/profiles/per-user/sgraf/home-manager-57-link -> /nix/store/lj5vs7pajby1nkhg66vpp78fb30bbbvx-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 4 17:08 /nix/var/nix/profiles/per-user/sgraf/home-manager-56-link -> /nix/store/hwm6hqii4g3bips4nk971svkml8i3d91-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 4 17:08 /nix/var/nix/profiles/per-user/sgraf/home-manager-55-link -> /nix/store/ci95b5n08090c264b7bwgl7lm2brlhgd-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 4 10:21 /nix/var/nix/profiles/per-user/sgraf/home-manager-54-link -> /nix/store/b2baa473dyc8db4nk6p3f9mgmwh0pd6h-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jun 4 09:45 /nix/var/nix/profiles/per-user/sgraf/home-manager-53-link -> /nix/store/4jc2yckqqzpij703azh6jfaqy9062xx1-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 30 10:47 /nix/var/nix/profiles/per-user/sgraf/home-manager-52-link -> /nix/store/34dq8aaifq6cd4xk5pp0qpvsva7amhm2-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 28 09:39 /nix/var/nix/profiles/per-user/sgraf/home-manager-51-link -> /nix/store/0h82qvn38snrgk9jxn6lfwz25qsvs8yf-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 14:47 /nix/var/nix/profiles/per-user/sgraf/home-manager-50-link -> /nix/store/5m6gr9cp1bygg1i8qn899118wv6nqkls-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 14:44 /nix/var/nix/profiles/per-user/sgraf/home-manager-49-link -> /nix/store/jh3llcs3csz8xzyqj33xc2q5i9sgcm16-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 12:49 /nix/var/nix/profiles/per-user/sgraf/home-manager-48-link -> /nix/store/5m6gr9cp1bygg1i8qn899118wv6nqkls-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 12:33 /nix/var/nix/profiles/per-user/sgraf/home-manager-47-link -> /nix/store/jh3llcs3csz8xzyqj33xc2q5i9sgcm16-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 10:29 /nix/var/nix/profiles/per-user/sgraf/home-manager-46-link -> /nix/store/z0mr441w08jmsamiy6m8jbahlvahg2hz-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 10:13 /nix/var/nix/profiles/per-user/sgraf/home-manager-45-link -> /nix/store/75nvcxl3k3gv3x56ry96f71kzvl929x1-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 09:44 /nix/var/nix/profiles/per-user/sgraf/home-manager-44-link -> /nix/store/n6q13ld58nfnl6ss9cqskva34qjbd54q-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 22 09:36 /nix/var/nix/profiles/per-user/sgraf/home-manager-43-link -> /nix/store/8m056n4xyb015a5fpq08cgfkdk5rhzwx-home-manager-generation
lrwxrwxrwx 1 sgraf mitarbeiter 67 May 17 10:48 /nix/var/nix/profiles/per-user/sgraf/home-manager-42-link -> /nix/store/8nfyrnv95s01hiflfviwnqv0wchabs88-home-manager-generation
/nix/var/nix/gcroots/per-user/sgraf:
total 4
lrwxrwxrwx 1 sgraf mitarbeiter 67 Jul 9 18:28 current-home -> /nix/store/parjmqbsv6vy31vv9rnabbzzx25wy9lx-home-manager-generation
I should probably add that I'm on Ubuntu 18.04. Also, maybe it's not that my home-manager
profile gets collected. Rather, the symptoms are that there is no home-manager
in path anymore and neither is any of the stuff I mention in my home.nix
.
Sorry for the delay. You're having a curious problem that I've never seen before. Everything seems as it should be in the output of the ls
command.
Unfortunately I'm not certain what it could be caused by. I'll just dump a bunch of questions and hopefully something will lead further.
So after a garbage collection, links that are created by Home Manager in your home directory end up not pointing to anything? What about your ~/.nix-profile
directory, is it completely emptied?
Which precise nix-collect-garbage
command are you running?
If you run nix-collect-garbage
, then /nix/var/nix/gcroots/per-user/sgraf/current-home/activate
, and finally nix-collect-garbage -v
does the second garbage collection print the things HM just created?
Does nix-store --gc --print-roots | grep home-manager
print similar paths as the ls
command?
Are you using Home Manager to manage your Bash or Z shell? If so do you have
. .nix-profile/etc/profile.d/nix.sh
in your ~/.profile
?
nix-store --gc --print-roots | grep home-manager
looks fine, except it was removing some stale links on first run (sorry there's no paste, I had already run nix-garbage-collect
deleting xclip
before realizing I should have copied the output first): One link from /nix/var/nix/gc-roots/per-user/sgraf/current-home
to the most recent generation and a bunch of links of the form of home-manager-xx-link
to the store.
I just ran another nix-garbage-collect
, which seemed to remove many things, including nix-env
(?!). At least, this is the output of /nix/var/nix/gcroots/per-user/sgraf/current-home/activate
:
Starting home manager activation
Activating checkLinkTargets
Activating writeBoundary
Activating uninstallHomeManager
/nix/var/nix/gcroots/per-user/sgraf/current-home/activate: line 112: nix-env: command not found
Activating installPackages
/nix/var/nix/gcroots/per-user/sgraf/current-home/activate: line 121: nix-env: command not found
locate nix-env
reveals that it's not completely gone, however there's no ~/.nix-profile
directory to source from. Also I realized that I still seem to have leftovers from Nix < 2.0 in my /nix
, so I'm completely wiping that directory now.
Now, on a completely fresh install (also switched from unstable to 18.03, shouldn't make much of a difference, I believe) nix-collect-garbage
still removes stuff, but the shell environment is still intact. Yay! Sorry for keeping you busy.
Actually, I hit this today in a less grave variant: I ran nix-collect-garbage -d
(emphasis on -d) and it removed all home-manager and nix tools again, at least from my path. Maybe it's related to me running nix store --optmize
before. Also, re-installing wasn't so involved this time, because it seems that my actual home-manager generation was still intact, so it just re-downloaded 10ish packages and I was good to go again in no time.
Sorry for the delay. If these packages are installed in your latest Home Manager profile then you shouldn't have to download them again. You can check the output of home-manager packages
and the actual content of the HM profile path to see if the packages are part of the HM profile. For example, for the home-manager tool I have
$ home-manager packages | grep '^home-manager$'
home-manager
$ find $(nix-env -q --out-path | grep -o '/.*home-manager-path') -path '*/bin/home-manager'
/nix/store/sr67x7l0n41lfbrhn5kb86ann07rkazx-home-manager-path/bin/home-manager
I get similar output as you do when I run those commands. Yet it keeps reinstalling packages after a nix-collect-garbage -d
, but it's really not that bad. Example output (after reinstalling nix
and extracting the home-manager
release):
these derivations will be built:
/nix/store/nmgwg4pi978d793a2kdq7chy8kbjw6jz-home-manager.drv
these paths will be fetched (2.25 MiB download, 11.32 MiB unpacked):
/nix/store/26lgqf0ja6rx8dnz972a3f56vfxmmmv5-xz-5.2.4-bin
/nix/store/61m8xswm9xxwb3ddw1za2cxvcikgk656-patch-2.7.6
/nix/store/63j8mi5vjyxfc89rhjknwxaxqg3a2sx2-paxctl-0.9
/nix/store/70k1sw727s6lcwgfaff02axbnsia4rz6-stdenv-linux
/nix/store/b0vzdhjgd296wmrxwg5cs3jwp7g72h4w-readline-7.0p5
/nix/store/bqp3d4yhpx6h60fv8jww5id0nkm44034-patchelf-0.9
/nix/store/d1mdka63hyv0sq961rzn771br9lxqkj2-bash-interactive-4.4-p23-info
/nix/store/i6vl5lwlz5jbkg4r6p340dwmj6fha3xq-stdenv-linux
/nix/store/ifgii4vwnjmfkikffywfw3qyqzsnr967-bash-interactive-4.4-p23-doc
/nix/store/kic17fw8wil74k04kzh3dha43izrr9j3-bash-interactive-4.4-p23-dev
/nix/store/kspghzdcy9wfdikc81mm8lm2gg3zn2w4-ed-1.14.2
/nix/store/lxbaya2mzjc3xzbcsykrcbvcf5vxvfia-gnutar-1.30
/nix/store/pd3xx55jjik53gvbyrs4h0him03l3wah-bash-interactive-4.4-p23
/nix/store/x9dp56w3pf370wl0rd4rmlidhhp6ijvm-bash-interactive-4.4-p23-man
copying path '/nix/store/ifgii4vwnjmfkikffywfw3qyqzsnr967-bash-interactive-4.4-p23-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/d1mdka63hyv0sq961rzn771br9lxqkj2-bash-interactive-4.4-p23-info' from 'https://cache.nixos.org'...
copying path '/nix/store/x9dp56w3pf370wl0rd4rmlidhhp6ijvm-bash-interactive-4.4-p23-man' from 'https://cache.nixos.org'...
copying path '/nix/store/kspghzdcy9wfdikc81mm8lm2gg3zn2w4-ed-1.14.2' from 'https://cache.nixos.org'...
copying path '/nix/store/lxbaya2mzjc3xzbcsykrcbvcf5vxvfia-gnutar-1.30' from 'https://cache.nixos.org'...
copying path '/nix/store/61m8xswm9xxwb3ddw1za2cxvcikgk656-patch-2.7.6' from 'https://cache.nixos.org'...
copying path '/nix/store/bqp3d4yhpx6h60fv8jww5id0nkm44034-patchelf-0.9' from 'https://cache.nixos.org'...
copying path '/nix/store/63j8mi5vjyxfc89rhjknwxaxqg3a2sx2-paxctl-0.9' from 'https://cache.nixos.org'...
copying path '/nix/store/b0vzdhjgd296wmrxwg5cs3jwp7g72h4w-readline-7.0p5' from 'https://cache.nixos.org'...
copying path '/nix/store/26lgqf0ja6rx8dnz972a3f56vfxmmmv5-xz-5.2.4-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/pd3xx55jjik53gvbyrs4h0him03l3wah-bash-interactive-4.4-p23' from 'https://cache.nixos.org'...
copying path '/nix/store/70k1sw727s6lcwgfaff02axbnsia4rz6-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/kic17fw8wil74k04kzh3dha43izrr9j3-bash-interactive-4.4-p23-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/i6vl5lwlz5jbkg4r6p340dwmj6fha3xq-stdenv-linux' from 'https://cache.nixos.org'...
building '/nix/store/nmgwg4pi978d793a2kdq7chy8kbjw6jz-home-manager.drv'...
install: creating directory '/nix/store/inghzn7lc9jz0a19v0dbk7bhfa0vn95a-home-manager'
install: creating directory '/nix/store/inghzn7lc9jz0a19v0dbk7bhfa0vn95a-home-manager/bin'
'/nix/store/lr47i8aksy501d2bp904fcwkjv88czyd-home-manager' -> '/nix/store/inghzn7lc9jz0a19v0dbk7bhfa0vn95a-home-manager/bin/home-manager'
Creating initial Home Manager generation...
these derivations will be built:
/nix/store/vjp6d22v2swfcxxkr99h68y4a4f7i1ik-options-db.xml.drv
/nix/store/7acg74qffl5hv39r6i71vb55jzyaz8k4-generated-docbook.drv
/nix/store/kyq1k3p4nphdm4xln5gwwwah7k82ky3a-home-manager-manual-combined.drv
/nix/store/1vi0d1kdkikl3gn0zzwxdcrcsqrq1y76-manual-olinkdb.drv
/nix/store/6vss1g9r1jljdra4qcd3l45z1gy5f76q-home-manager-manpages.drv
/nix/store/rk5hm50715cym4awj8ji47gd1vf0xbs7-home-manager-path.drv
/nix/store/fkjhzrrv5l6awi0glkcl8zzqd9apks65-activation-script.drv
/nix/store/4ip0nri0wzlpfn7gv4yh2k9fyp9w3zsx-home-manager-generation.drv
these paths will be fetched (1.33 MiB download, 20.48 MiB unpacked):
/nix/store/00ngkh3898nn72kgm2p6xkh2h82kw8z8-hook
/nix/store/103nvj59bjc4c7ds7xnd4ivnfja3jaaq-gcc-wrapper-7.3.0-man
/nix/store/bsyhhflcd1f3xg8b5xzc063r4c49p8p7-docbook-xsl-ns-1.79.1
/nix/store/gd0vpaa6lnjxk25n35k070li5rv6ap3i-libxslt-1.1.32-bin
/nix/store/glfq6f14gb1c5by4vnkb3j5yg1cpynj7-libxml2-2.9.8-bin
/nix/store/ndjp4szbpb4906vqrj1sp5gsbsm8klvd-docbook5-5.0
copying path '/nix/store/103nvj59bjc4c7ds7xnd4ivnfja3jaaq-gcc-wrapper-7.3.0-man' from 'https://cache.nixos.org'...
copying path '/nix/store/ndjp4szbpb4906vqrj1sp5gsbsm8klvd-docbook5-5.0' from 'https://cache.nixos.org'...
copying path '/nix/store/00ngkh3898nn72kgm2p6xkh2h82kw8z8-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/glfq6f14gb1c5by4vnkb3j5yg1cpynj7-libxml2-2.9.8-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/bsyhhflcd1f3xg8b5xzc063r4c49p8p7-docbook-xsl-ns-1.79.1' from 'https://cache.nixos.org'...
copying path '/nix/store/gd0vpaa6lnjxk25n35k070li5rv6ap3i-libxslt-1.1.32-bin' from 'https://cache.nixos.org'...
building '/nix/store/vjp6d22v2swfcxxkr99h68y4a4f7i1ik-options-db.xml.drv'...
building '/nix/store/7acg74qffl5hv39r6i71vb55jzyaz8k4-generated-docbook.drv'...
building '/nix/store/kyq1k3p4nphdm4xln5gwwwah7k82ky3a-home-manager-manual-combined.drv'...
manual-combined.xml validates
man-pages-combined.xml validates
building '/nix/store/1vi0d1kdkikl3gn0zzwxdcrcsqrq1y76-manual-olinkdb.drv'...
Writing /nix/store/idkknx4m23wq04slhhjr9qhcl65ir91y-manual-olinkdb/manual.db for book(book-home-manager-manual)
building '/nix/store/6vss1g9r1jljdra4qcd3l45z1gy5f76q-home-manager-manpages.drv'...
Note: Writing /nix/store/giszyjra8rzywhxvjrzsbb3csvjyqwqi-home-manager-manpages/share/man/man5/home-configuration.nix.5
Note: Writing /nix/store/giszyjra8rzywhxvjrzsbb3csvjyqwqi-home-manager-manpages/share/man/man8/home-manager.8
building '/nix/store/rk5hm50715cym4awj8ji47gd1vf0xbs7-home-manager-path.drv'...
created 4451 symlinks in user environment
building '/nix/store/fkjhzrrv5l6awi0glkcl8zzqd9apks65-activation-script.drv'...
building '/nix/store/4ip0nri0wzlpfn7gv4yh2k9fyp9w3zsx-home-manager-generation.drv'...
/nix/store/w0wzz40hdxhs0kvpjckd8ip8lsjsxf0g-home-manager-generation
Starting home manager activation
This takes like a minute is totally acceptable.
Yeah, these packages are needed to build the actual Home Manager generation but are not needed afterwards so the GC will remove them.
Currently, everytime I
nix-collect-garbage
, myhome-manager
profile gets collected, too. Is this intended? If so, what would I do to collect old generations?