tl;dr Hi, I’m a software developer and a nixos user, but no real development experience with nix toolchain (other than using nixos for my laptop). I’m trying to learn though - so my question: how do I locally override just a single line in a large string of a package I have installed on my system?
I’ve been reading up on nix language and saw that this is a very normal use-case. I think my end goal would be running my own “derivation” of said package I’m debugging? But I’m unsure what the syntax would look like in my case.
I think I should be able to test this in nix repl maybe(?) with some syntax like:
someNixPackageName { installPhase = ''
my copy/pasted tweak of that huge string
''
}
Am I on the right track? Any pointers appreciated! eg: I’d define a new .nix file - probably anywhere(?) and just run it directly as a one-off test (with what command?) to get a shell with just this one-off derivation installed?
Yes, you can clone the Nixpkgs repository, do whatever changes you wish to test, and then build a package or even rebuild your NixOS installation from this modified checkout. Do you want to just test a package or use the modifications for a NixOS service?
Ah I hadn’t thought of cloning the repo. I was thinking I’d need to modify my own existing .nix files to refer to this upstream repo/package. But cloning the repo sounds fine too…
If I want to just test and throw-away the test (rather than add a new iteration to my system’s versions), would that be via nix-shell -p ..local-path-to-cloned-.nix-file or some such?
I want to test the package, assuming I’ll want to then go upstream the fix (with new confidence that I know it’s a correct fix). However I also want to know how I’d just keep the fix to myself (say we just disagreed about this fix and no one wants me to upstream it: how would I just override this one line in my own system’s .nix files?).
The simplest solution would be cloning Nixpkgs locally (e.g. to ~/Projects/nixpkgs) and just modifying the file directly. Then, you will be able to build the derivation in the ~/Projects/nixpkgs directory with nix-build --expr 'let pkgs = import ./. {}; in pkgs.dictDBCollector { dictlist = []; }'' or nix repl. You can even rebuild your system with this copy of Nixpkgs by passing -I nixpkgs="$HOME/Projects/nixpkgs" to nixos-rebuild (or --override-input "$HOME/Projects/nixpkgs" with Flakes).
Alternately, stdenv.mkDerivation from Nixpkgs allows you to create modified derivations using overrideAttrs function. You could use it from e.g. repl without modifying any files.
But you would have to call that on the result of mkDerivation:
(This also depends on how much of the system should see the change — a lot of things are possible, but cost/benefit trade-off is determined by the use case)
thanks to both of you. for my edification I want to try both routes that jtojnar suggested. Starting with the nix-build based off a local edit to a clone of the pkgs repo…
I’m realizing that, regardless of the strategy I pick, I should first establish a baseline for myself: reproduce the error I’m trying to fix. So I did the following, from the freshly cloned packages repo, I’m trying to trigger installPhase code to run:
git checkout 22.05 (as that is what’s in my system’s file’s system.stateVersion value)
did not make my planned edits yet
from the root of the git repo, ran nix-build --expr 'let pkgs = import ./. {}; in pkgs.dictDBCollector { dictlist = []; }'
now try to reproduce the error by getting installPhase to execute…
Reading the nixos-rebuild manpage I think build-vm would be nice or even test (so I don’t add another boot entry for this tinkering). I’ve tried both:
both of those^ commands result all sorts of lines of my /etc/nixos/*.nix files having issues. Issues I don’t see day to day when I run nixos-rebuild switch on a regular basis (just managing personal package selections). here’s a snippet of the error:
error: The option `fonts.enableDefaultPackages' does not exist. Definition values:
- In `/etc/nixos/configuration.nix': true
I can comment that out just to get this test font package’s config to move the test along, but then some other mundane thing causes a similar error: virtualisation.vmVariant.users.users.qsu.linger' does not exist.
I’m guessing I’m just misunderstanding how the repo is relating to my real system, or I’m misunderstanding the suggested approach?
Trying to impact my real/working laptop as little as possible. Isolate my hypothesis of “this is how to fix the bug” to some ephemeral configs/changes that won’t stick around. So the build-vm or test options I found seem to be what I’d intended.
Got it, thanks. Seems there’s a lot of flexibility, but that means lots of nix architecture I need to learn to grok my options better. I’ll start with jtojnar’s two ideas and see what happens.
stateVersion has little to do with what version of Nixpkgs are you using. It is really just to make sure NixOS modules for stateful programs can evolve without breaking existing systems on updates.
And 22.05 is actually a git tag that points to the state of the Nixpkgs repo at the time NixOS 22.05 was released so I hope you are not using it on your system – you would be missing almost two years of updates.
You can get the version of your system using nixos-version:
You can checkout that commit, or the branch corresponding to the NixOS channel you use:
nixos-unstable for unstable
release-23.11 for stable
You can find the channel using sudo nix-channel --list (if you use Flakes, look into the inputs section of. flake.nix). You will also see the branch if you open the commit on GitHub.
That sounds like it might just be incompatibility because of too old Nixpkgs revision.
stateVersion is for things like «oh we put this database in that path, we have a better idea now but migration is not worth the trouble».
You presumably use a system that is fresher than 23.11 (even if you use stable there has been some updates, and unstable has been developed quite a bit since the release). You configuration uses this year’s options not the old ones.
(But stateVersion should indeed stay at 22.05, because location of stateful stuff follows the older conventions)
My question was more of the type of «what do you plan to do to reproduce the bug». But yeah, if build-vm sounds reasonable, then nix-shell/nix-build/nix-repl invocations are not for this case.
test should be fine: the change is minor, so it is well within the safety margins of going back to the previous NixOS system instance. (We say that you can «almost always» roll back, of course there are corner cases like «reinstalling the bootloader wrong needs more effort to roll back than choosing a boot menu entry» or even «if your daemons have upgraded the schema of their mutable state automatically, uhm» — but dictd doesn’t need any mutable state)
tl;dr learning, thanks! down to trying to provably trigger installPhase now…
Okay I just learned a ton thanks. Indeed my nixos-version has the same exact
output as jtojnar’s 4-day-old commit. Also thanks to both for re-explaining
what stateVersion is really doing - I totally forgot about channels, and think
I’ve even learned this nixos concept about state before too. Nix is just so new
and different guess it’ll take me some time to start remembering
this stuff.
Perfect - doing git checkout bd645e8 and re-running step 4 got me past the
conflict with my own /etc/nixos/ configs. However I’m at a new point of
confusion: I can’t reproduce the error. I’m guessing both my own derivation and
this local-package’s derivation are not actually re-running installPhase
because… they’re already on my system? Are my attempts (below) to remove it via test insufficient (will it only ever run if I execute switch)? Specifically here’s what I’m seeing:
nixos-rebuild build-vm seemed top be taking me down a rabbit hole…
...rabbit hole that I figure isn't worth following for now...
$ nixos-rebuild --show-trace build-vm -I nixpkgs=~qsu/src/nixpkgs
# snipped trace, for brevity
error:
Failed assertions:
- boot.loader.initrd.secrets values must be unquoted paths when
using a bootloader that doesn't natively support initrd
secrets, e.g.:
boot.initrd.secrets = {
"/etc/secret" = /path/to/secret;
};
Note that this will result in all secrets being stored
world-readable in the Nix store!
nixos-rebuild test seems to succeed, but seems not to trigger installPhase (I see now errors); just get an interesting warning about a
collision:
first trying to nixos-rebuild test and realizing nixos probably(?) has no
reason to run installPhase for me…
CLI output from `nixos-rebuild test` call
$ nixos-rebuild --show-trace test -I nixpkgs=~qsu/src/nixpkgs
building Nix...
building the system configuration...
these 24 derivations will be built:
/nix/store/02kp1hkv7f22mxrdlaxz82csy62h9fcf-etc-os-release.drv
/nix/store/d4255hhmvwbnmhqmpvnr52pzfqmh7mhw-nixos-manual-html.drv
/nix/store/jyym04za6z3m5ihr00kmkahj56xpj8dh-nixos-help.drv
/nix/store/bskwmzmr5l36m2va9nbnjdkhx6ghzzsb-nixos-help.drv
/nix/store/m28jr92nnhcg7mi5yig0b0am56yialik-nixos-version.drv
/nix/store/486a2ppwcmjj1mwyk9yxs20814s4ifqr-system-path.drv
/nix/store/80lg5842lfspbdhly008v1r4jpxi1j50-X-Restart-Triggers-polkit.drv
/nix/store/312vrws3nxlg547g7brwdxkcg8jb5m1b-unit-polkit.service.drv
/nix/store/mmnd2rsk4wssg4kahbgxa3vmdhpw6s8y-dbus-1.drv
/nix/store/3w67b83mwjcj0nwbl5qx9wdbh9wc6azv-X-Restart-Triggers-dbus.drv
/nix/store/4lmnw1n8ic3r4nxlawmf2lxr3rfsgirn-set-environment.drv
/nix/store/6inhrj3s51v0f3ph7998if9f2fcfhh1r-unit-dbus.service.drv
/nix/store/67q43lq6ixardsbzmd38rid29lgzs81c-user-units.drv
/nix/store/v57b8mjhg4dmsx9giddl88c98cx7ma86-shutdown-ramfs-contents.drv
/nix/store/a29fqkf9w80j77drv2v30qya9apcy8kk-unit-generate-shutdown-ramfs.service.drv
/nix/store/kijw4zca7hijl772zyxg5mray35djgx4-unit-dbus.service.drv
/nix/store/q2s2bd3lw6b00598g5ij8lmil64gyqcd-unit-accounts-daemon.service.drv
/nix/store/lbssqhhj68rdahc3ywawif80y5r2hpba-system-units.drv
/nix/store/pj4877p68slwn3dazxzsmjsywwh8jrcf-etc-pam-environment.drv
/nix/store/valbm4wzwds7pcq1pb69bzxwkspq8160-issue.drv
/nix/store/wxqg1xinm84li3w976bs3sclddgwlmr7-etc-profile.drv
/nix/store/ibsrmc2ixlrb210kj9bxxk673nshw5px-etc.drv
/nix/store/qjclb2ffd8304qfi0bzd2ahyhsw3drja-boot.json.drv
/nix/store/lgrppqvsifgf964lk5js8pa5wfwh32rc-nixos-system-laptop-24.05.git.bd645e8668ec.drv
building '/nix/store/qjclb2ffd8304qfi0bzd2ahyhsw3drja-boot.json.drv'...
building '/nix/store/02kp1hkv7f22mxrdlaxz82csy62h9fcf-etc-os-release.drv'...
building '/nix/store/valbm4wzwds7pcq1pb69bzxwkspq8160-issue.drv'...
building '/nix/store/m28jr92nnhcg7mi5yig0b0am56yialik-nixos-version.drv'...
building '/nix/store/d4255hhmvwbnmhqmpvnr52pzfqmh7mhw-nixos-manual-html.drv'...
building '/nix/store/v57b8mjhg4dmsx9giddl88c98cx7ma86-shutdown-ramfs-contents.drv'...
building '/nix/store/a29fqkf9w80j77drv2v30qya9apcy8kk-unit-generate-shutdown-ramfs.service.drv'...
building '/nix/store/jyym04za6z3m5ihr00kmkahj56xpj8dh-nixos-help.drv'...
building '/nix/store/bskwmzmr5l36m2va9nbnjdkhx6ghzzsb-nixos-help.drv'...
building '/nix/store/486a2ppwcmjj1mwyk9yxs20814s4ifqr-system-path.drv'...
warning: collision between `/nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420/share/dictd/locale' and `/nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542/share/dictd/locale'
created 21778 symlinks in user environment
gtk-update-icon-cache: Cache file created successfully.
gtk-update-icon-cache: Cache file created successfully.
building '/nix/store/80lg5842lfspbdhly008v1r4jpxi1j50-X-Restart-Triggers-polkit.drv'...
building '/nix/store/mmnd2rsk4wssg4kahbgxa3vmdhpw6s8y-dbus-1.drv'...
building '/nix/store/pj4877p68slwn3dazxzsmjsywwh8jrcf-etc-pam-environment.drv'...
building '/nix/store/4lmnw1n8ic3r4nxlawmf2lxr3rfsgirn-set-environment.drv'...
building '/nix/store/q2s2bd3lw6b00598g5ij8lmil64gyqcd-unit-accounts-daemon.service.drv'...
building '/nix/store/3w67b83mwjcj0nwbl5qx9wdbh9wc6azv-X-Restart-Triggers-dbus.drv'...
building '/nix/store/wxqg1xinm84li3w976bs3sclddgwlmr7-etc-profile.drv'...
building '/nix/store/312vrws3nxlg547g7brwdxkcg8jb5m1b-unit-polkit.service.drv'...
building '/nix/store/6inhrj3s51v0f3ph7998if9f2fcfhh1r-unit-dbus.service.drv'...
building '/nix/store/kijw4zca7hijl772zyxg5mray35djgx4-unit-dbus.service.drv'...
building '/nix/store/67q43lq6ixardsbzmd38rid29lgzs81c-user-units.drv'...
building '/nix/store/lbssqhhj68rdahc3ywawif80y5r2hpba-system-units.drv'...
building '/nix/store/ibsrmc2ixlrb210kj9bxxk673nshw5px-etc.drv'...
building '/nix/store/lgrppqvsifgf964lk5js8pa5wfwh32rc-nixos-system-laptop-24.05.git.bd645e8668ec.drv'...
Could not open lock - Permission denied at /nix/store/rr6c975m14h96n71sn7zzq79aqap55d1-nixos-system-laptop-24.05.git.bd645e8668ec/bin/switch-to-configuration line 95.
warning: error(s) occurred while switching to the new configuration
$ sudo nixos-rebuild --show-trace test -I nixpkgs=~qsu/src/nixpkgs
Place your right index finger on the fingerprint reader
building Nix...
building the system configuration...
stopping the following units: accounts-daemon.service
activating the configuration...
setting up /etc...
reloading user units for qsu...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service
second, trying to nixos-rebuild test again a handful of times, this time
trying to disable/renable an actually installation phase, to no avail:
output here of ($EDITOR, rebuild, $EDITOR, rebuild)-cycle
# temporarily disabled dictd via `services.dictd.enable = false;` and deleting all pkg lines that seem `dictd` related:
# dict
# dictdDBs.wordnet
# dictdDBs.wiktionary
$ sudo nvim /etc/nixos/configuration.nix
# rebuild now, hoping that dictd is sufficiently uninstalled
$ sudo nixos-rebuild --show-trace test -I nixpkgs=~qsu/src/nixpkgs
building Nix...
building the system configuration...
these 15 derivations will be built:
/nix/store/ww0y8ac5ir6yhwpm8zgnyv5qq52k4xjg-system-path.drv
/nix/store/0pfisk6z88bfxy90j67xvyfppnp5als2-etc-pam-environment.drv
/nix/store/37hcdjvzkchclslgvwr1lzpz7g8wysq1-X-Restart-Triggers-polkit.drv
/nix/store/24qrr215y34h78szkxl71kk9glzxxn7z-unit-polkit.service.drv
/nix/store/i718kfqjd4y5f379mdz1l1inhiv3zplm-unit-accounts-daemon.service.drv
/nix/store/gg87nx9qsm7r2swk7s3savg3v33wbbkb-dbus-1.drv
/nix/store/k2w582hfrhmn8yy2k7phh0hfv3j3pr98-X-Restart-Triggers-dbus.drv
/nix/store/ncpfcbd08jcafr2db8qvji2yi4xn1agy-unit-dbus.service.drv
/nix/store/29izs7nv8px1in3z9i05inw61xc5xf91-system-units.drv
/nix/store/yc1rif8k576vr3n41vinqshcjwk2kjjm-set-environment.drv
/nix/store/45q9jzzvzrmpr0w6vzsrrf3k1q48mfsb-etc-profile.drv
/nix/store/bxwjdd46rdwfj3zzqlacmwhrz6mr1c4m-unit-dbus.service.drv
/nix/store/9zrv3yk7ajiyhqlhf4snwj6jx9yx3qmg-user-units.drv
/nix/store/ayx5c90my2lwm1iw95nlzlsrgclhhhgc-etc.drv
/nix/store/akjpsiw2305d4a39a03q8mkc9znx28r7-nixos-system-laptop-24.05.git.bd645e8668ec.drv
building '/nix/store/ww0y8ac5ir6yhwpm8zgnyv5qq52k4xjg-system-path.drv'...
created 21739 symlinks in user environment
gtk-update-icon-cache: Cache file created successfully.
gtk-update-icon-cache: Cache file created successfully.
building '/nix/store/37hcdjvzkchclslgvwr1lzpz7g8wysq1-X-Restart-Triggers-polkit.drv'...
building '/nix/store/gg87nx9qsm7r2swk7s3savg3v33wbbkb-dbus-1.drv'...
building '/nix/store/0pfisk6z88bfxy90j67xvyfppnp5als2-etc-pam-environment.drv'...
building '/nix/store/yc1rif8k576vr3n41vinqshcjwk2kjjm-set-environment.drv'...
building '/nix/store/i718kfqjd4y5f379mdz1l1inhiv3zplm-unit-accounts-daemon.service.drv'...
building '/nix/store/k2w582hfrhmn8yy2k7phh0hfv3j3pr98-X-Restart-Triggers-dbus.drv'...
building '/nix/store/45q9jzzvzrmpr0w6vzsrrf3k1q48mfsb-etc-profile.drv'...
building '/nix/store/24qrr215y34h78szkxl71kk9glzxxn7z-unit-polkit.service.drv'...
building '/nix/store/bxwjdd46rdwfj3zzqlacmwhrz6mr1c4m-unit-dbus.service.drv'...
building '/nix/store/ncpfcbd08jcafr2db8qvji2yi4xn1agy-unit-dbus.service.drv'...
building '/nix/store/9zrv3yk7ajiyhqlhf4snwj6jx9yx3qmg-user-units.drv'...
building '/nix/store/29izs7nv8px1in3z9i05inw61xc5xf91-system-units.drv'...
building '/nix/store/ayx5c90my2lwm1iw95nlzlsrgclhhhgc-etc.drv'...
building '/nix/store/akjpsiw2305d4a39a03q8mkc9znx28r7-nixos-system-laptop-24.05.git.bd645e8668ec.drv'...
stopping the following units: accounts-daemon.service, dictd.service
activating the configuration...
removing group ‘dictd’
removing user ‘dictd’
setting up /etc...
removing obsolete symlink ‘/etc/dict.conf’...
reloading user units for qsu...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service
Good? That does show “removing user dictd” and such…
# re-enabled dictd via `services.dictd.enable = false;`
$ sudo nvim /etc/nixos/configuration.nix
# rebuild now, hoping that dictd goes through full install phase...
$ sudo nixos-rebuild --show-trace test -I nixpkgs=~qsu/src/nixpkgs
building Nix...
building the system configuration...
stopping the following units: accounts-daemon.service
activating the configuration...
setting up /etc...
reloading user units for qsu...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service
the following new units were started: dictd.service
No good No error output above; which I’m guessing means I’m not actually
running installPhase as I expect.
Well, silly idea: maybe try checking out the exact revision where you did have an error? Maybe even do nixos-rebuild build instead of test as you don’t really care about running that configuration.
Also note: installPhase is a part of the package build (not system activation). So if a package is built succesfully once, the installPhase does not need to run again. (For failed package builds, though, Nix will retry the build).
As for reproducing the error — I wouldn’t be surprised if the problem was related to a missing locale file in one dictionary package, and that it ended up fixed as a side-effect of the recent «get rid of randomly changing part in the build output» commits.
Edited to add: also, from the other thread it looks like the package build treated the complaint as a warning?
Anyway, if you want to make sure installPhase runs again, you can locally add an echo Hello World line into the installPhase, that will force the rebuild for sure.
that did it! even with test I can finally see the installPhase run (and the error trigger)
Ah, no: the reason for this change is because I’m 99% sure the CLI parsing of the command being called is not happy with space-delimited arguments on flags. That is: its CLI parsing is implemented such that it expects --a=b not --a b, thus the current script’s way (of passing in --locale into it) can never work. See this writeup:
The question is that the package build pretends to be succesful anyway (which is why it was not rerun). But it looks likely that the results are suboptimal, as you explain
tl;dr think I’m all set now. TIL some general nix things, learned how to test simple patches to a package without modifying my grub history, and bonus: confirmed my fix to the dictd indeed works.
finally reproducing the error without introducing my fix just
yet (and thus possibly confusing any testing)
$ sudo nixos-rebuild --show-trace test -I nixpkgs=~qsu/src/nixpkgs
Place your right index finger on the fingerprint reader
building Nix...
building the system configuration...
these 28 derivations will be built:
/nix/store/2wpvrm9abhccqhhhkqydbnqhjxnq46a9-nixos-manual-html.drv
/nix/store/77bb9sy1c2zyydvws1cdr8zmq0zzx8gl-nixos-version.drv
/nix/store/1ajik25g4fkfkf14pyiqgfra1j37095q-nixos-help.drv
/nix/store/qbfqrcikfzx5l7myl2y1gcgqa6im4arg-nixos-help.drv
/nix/store/xc96gc0zz0723bilj3d12y5bc0rf3wqm-system-path.drv
/nix/store/1191gv1xs25dxpg3qdc73j901hxmc6cr-set-environment.drv
/nix/store/1avpgnx3nnij53j48iaivs3jxxnp4q5a-boot.json.drv
/nix/store/6fsv1h7sb3zy4dl0n5dz7dib6ai3zy54-dictd-dbs.drv
/nix/store/25zdnz15z515bvh2mfx1cdkgnhay6nwm-users-groups.json.drv
/nix/store/4pn1zvj2a9iq4bv27pa090y466srmwpy-dbus-1.drv
/nix/store/5gqm3ppsnk3gdx1s7729cvc7g6w271kh-etc-os-release.drv
/nix/store/mw3vr5jlaarwxays4krmw5q8y52gkjz7-unit-script-dictd-start.drv
/nix/store/6viy1ivlb06dylvhx38ry122as6zyrzq-unit-dictd.service.drv
/nix/store/w33ns84d8mcphabdkj2mmr5jp28izgpc-X-Restart-Triggers-polkit.drv
/nix/store/8dd0qivr780p69hip93i8snd04m7pm4r-unit-polkit.service.drv
/nix/store/h2dq63h0cz1xvk64cyjnp5p2mkrm5czi-X-Restart-Triggers-dbus.drv
/nix/store/mzr1rwpxf91m7s3pyb478mbawvv2z0iw-unit-dbus.service.drv
/nix/store/9qxkdsya1m0m1pmzkf09rjk21dg9kx7p-user-units.drv
/nix/store/nb4ymxpz2gkyq3zgicazb1jlhkm688qx-issue.drv
/nix/store/p4mc4n4im97as0hj2lppmcspgvdvjl1k-etc-pam-environment.drv
/nix/store/mj8ihbilppbhsdsc6ncgk73hqy2nmivb-shutdown-ramfs-contents.drv
/nix/store/v0d5w74ck93nayj6gvq904ijq0blv2x8-unit-generate-shutdown-ramfs.service.drv
/nix/store/v5phmvl2cfk29wkm0k2ginhrlgvf2ms4-unit-accounts-daemon.service.drv
/nix/store/ws1calscxya5mvhpp33i258aavsmqs0q-unit-dbus.service.drv
/nix/store/pmv4vsprmr712p19c8qzsk3fif5s8x7c-system-units.drv
/nix/store/qf62v7kyjkxsnhllyimi1mmrv3lw7snj-etc-profile.drv
/nix/store/l1dmjv3s5d2vq5q4iqdp60g0gh9sci3q-etc.drv
/nix/store/hkglharh9ngwz290jy69lan3j9205hjz-nixos-system-laptop-24.05.git.bd645e8668ecM.drv
building '/nix/store/1avpgnx3nnij53j48iaivs3jxxnp4q5a-boot.json.drv'...
building '/nix/store/5gqm3ppsnk3gdx1s7729cvc7g6w271kh-etc-os-release.drv'...
building '/nix/store/nb4ymxpz2gkyq3zgicazb1jlhkm688qx-issue.drv'...
building '/nix/store/77bb9sy1c2zyydvws1cdr8zmq0zzx8gl-nixos-version.drv'...
building '/nix/store/6fsv1h7sb3zy4dl0n5dz7dib6ai3zy54-dictd-dbs.drv'...
building '/nix/store/2wpvrm9abhccqhhhkqydbnqhjxnq46a9-nixos-manual-html.drv'...
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
Got store path /nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420
Directory reference: /nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420/share/dictd
Basename is /nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420/share/dictd/wiktionary-en
building '/nix/store/mj8ihbilppbhsdsc6ncgk73hqy2nmivb-shutdown-ramfs-contents.drv'...
Locale is en_US.UTF-8
/nix/store/d4jf1cbbk494zwgbqz31pxgigpsbh6w2-stdenv-linux/setup: line 1583: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
hello world
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
awk: cmd. line:4: fatal: cannot open file `en_US.UTF-8' for reading: No such file or directory
dictfmt: option '--locale' requires an argument
dictfmt-1.13.1
Copyright 1997-2000 Rickard E. Faith (faith@cs.unc.edu)
Copyright 2002-2007 Aleksey Cheusov (vle@gmx.net)
Usage: dictfmt -c5|-t|-e|-f|-h|-j|-p [-u url] [-s name] [options] basename
dictfmt -i|-I [options]
Create a dictionary database and index file for use by a dictd server
-c5 headwords are preceded by a line containing at least
5 underscore (_) characters
-t implies -c5, --without-headword and --without-info options
-e file is in html format
-f headwords start in col 0, definitions start in col 8
-j headwords are set off by colons
-p headwords are preceded by %p, with %d on following line
-i reformat stdin having three-column .index file format
-u <url> URL of site where database was obtained
-s <name> name of the database
--license
-L display copyright and license information
--version
-V display version information
-D debug
--utf8 for creating utf-8 dictionary
--quiet
--silent
-q quiet operation
--help display this help message
--locale <locale> specifies the locale used for sorting.
if no locale is specified, the "C" locale is used.
--allchars all characters (not only alphanumeric and space)
will be used in search if this argument is supplied
--headword-separator <sep> sets headword separator which allows
several words to have the same definition
Example: autumn%%%fall can be used
if '--headword-separator %%%' is supplied
--index-data-separator <sep> sets index/data separator which allows
to explicitly set fourth column in .index file,
the default is "\034"
--break-headwords multiple headwords will be written on separate lines
in the .dict file. For use with '--headword-separator.
--index-keep-orig fourth column in .index file stores original headword
which is returned by MATCH command
--case-sensitive Create .index/.dict files for case sensitive search
--without-headword headwords will not be copied to .dict file
--without-header header will not be copied to DB info entry
--without-url URL will not be copied to DB info entry
--without-time time of creation will not be copied to DB info entry
--without-info DB info entry will not be created.
This may be useful if 00-database-info headword
is expected from stdin (dictunformat outputs it).
--columns Set the number of columns for wrapping text
before writing it to .dict file.
If it is zero, wrapping is off.
--default-strategy Sets the default search strategy for the database.
Special entry 00-database-default-strategy is created
for this purpose.
--mime-header Sets MIME header stored in .data file which
prepend definition
when client sent OPTION MIME to `dictd'
--without-ver do not create 00-database-dictfmt-<VER> entry in .index
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
dictfmt: option '--locale' requires an argument
dictfmt-1.13.1
Copyright 1997-2000 Rickard E. Faith (faith@cs.unc.edu)
Copyright 2002-2007 Aleksey Cheusov (vle@gmx.net)
Usage: dictfmt -c5|-t|-e|-f|-h|-j|-p [-u url] [-s name] [options] basename
dictfmt -i|-I [options]
Create a dictionary database and index file for use by a dictd server
-c5 headwords are preceded by a line containing at least
5 underscore (_) characters
-t implies -c5, --without-headword and --without-info options
-e file is in html format
-f headwords start in col 0, definitions start in col 8
-j headwords are set off by colons
-p headwords are preceded by %p, with %d on following line
-i reformat stdin having three-column .index file format
-u <url> URL of site where database was obtained
-s <name> name of the database
--license
-L display copyright and license information
--version
-V display version information
-D debug
--utf8 for creating utf-8 dictionary
--quiet
--silent
-q quiet operation
--help display this help message
--locale <locale> specifies the locale used for sorting.
if no locale is specified, the "C" locale is used.
--allchars all characters (not only alphanumeric and space)
will be used in search if this argument is supplied
--headword-separator <sep> sets headword separator which allows
several words to have the same definition
Example: autumn%%%fall can be used
if '--headword-separator %%%' is supplied
--index-data-separator <sep> sets index/data separator which allows
to explicitly set fourth column in .index file,
the default is "\034"
--break-headwords multiple headwords will be written on separate lines
in the .dict file. For use with '--headword-separator.
--index-keep-orig fourth column in .index file stores original headword
which is returned by MATCH command
--case-sensitive Create .index/.dict files for case sensitive search
--without-headword headwords will not be copied to .dict file
--without-header header will not be copied to DB info entry
--without-url URL will not be copied to DB info entry
--without-time time of creation will not be copied to DB info entry
--without-info DB info entry will not be created.
This may be useful if 00-database-info headword
is expected from stdin (dictunformat outputs it).
--columns Set the number of columns for wrapping text
before writing it to .dict file.
If it is zero, wrapping is off.
--default-strategy Sets the default search strategy for the database.
Special entry 00-database-default-strategy is created
for this purpose.
--mime-header Sets MIME header stored in .data file which
prepend definition
when client sent OPTION MIME to `dictd'
--without-ver do not create 00-database-dictfmt-<VER> entry in .index
gawk: cmd. line:25: fatal: cannot open file `en_US.UTF-8' for reading: No such file or directory
Got store path /nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542
Directory reference: /nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542/share/dictd
Basename is /nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542/share/dictd/wn
Locale is en_US.UTF-8
/nix/store/d4jf1cbbk494zwgbqz31pxgigpsbh6w2-stdenv-linux/setup: line 1583: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
building '/nix/store/v0d5w74ck93nayj6gvq904ijq0blv2x8-unit-generate-shutdown-ramfs.service.drv'...
hello world
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
dictfmt: option '--locale' requires an argument
dictfmt-1.13.1
Copyright 1997-2000 Rickard E. Faith (faith@cs.unc.edu)
Copyright 2002-2007 Aleksey Cheusov (vle@gmx.net)
Usage: dictfmt -c5|-t|-e|-f|-h|-j|-p [-u url] [-s name] [options] basename
dictfmt -i|-I [options]
Create a dictionary database and index file for use by a dictd server
-c5 headwords are preceded by a line containing at least
5 underscore (_) characters
-t implies -c5, --without-headword and --without-info options
-e file is in html format
-f headwords start in col 0, definitions start in col 8
-j headwords are set off by colons
-p headwords are preceded by %p, with %d on following line
-i reformat stdin having three-column .index file format
-u <url> URL of site where database was obtained
-s <name> name of the database
--license
-L display copyright and license information
--version
-V display version information
-D debug
--utf8 for creating utf-8 dictionary
--quiet
--silent
-q quiet operation
--help display this help message
--locale <locale> specifies the locale used for sorting.
if no locale is specified, the "C" locale is used.
--allchars all characters (not only alphanumeric and space)
will be used in search if this argument is supplied
--headword-separator <sep> sets headword separator which allows
several words to have the same definition
Example: autumn%%%fall can be used
if '--headword-separator %%%' is supplied
--index-data-separator <sep> sets index/data separator which allows
to explicitly set fourth column in .index file,
the default is "\034"
--break-headwords multiple headwords will be written on separate lines
in the .dict file. For use with '--headword-separator.
--index-keep-orig fourth column in .index file stores original headword
which is returned by MATCH command
--case-sensitive Create .index/.dict files for case sensitive search
--without-headword headwords will not be copied to .dict file
--without-header header will not be copied to DB info entry
--without-url URL will not be copied to DB info entry
--without-time time of creation will not be copied to DB info entry
--without-info DB info entry will not be created.
This may be useful if 00-database-info headword
is expected from stdin (dictunformat outputs it).
--columns Set the number of columns for wrapping text
before writing it to .dict file.
If it is zero, wrapping is off.
--default-strategy Sets the default search strategy for the database.
Special entry 00-database-default-strategy is created
for this purpose.
--mime-header Sets MIME header stored in .data file which
prepend definition
when client sent OPTION MIME to `dictd'
--without-ver do not create 00-database-dictfmt-<VER> entry in .index
awk: cmd. line:4: fatal: cannot open file `en_US.UTF-8' for reading: No such file or directory
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
dictfmt: option '--locale' requires an argument
dictfmt-1.13.1
Copyright 1997-2000 Rickard E. Faith (faith@cs.unc.edu)
Copyright 2002-2007 Aleksey Cheusov (vle@gmx.net)
Usage: dictfmt -c5|-t|-e|-f|-h|-j|-p [-u url] [-s name] [options] basename
dictfmt -i|-I [options]
Create a dictionary database and index file for use by a dictd server
-c5 headwords are preceded by a line containing at least
5 underscore (_) characters
-t implies -c5, --without-headword and --without-info options
-e file is in html format
-f headwords start in col 0, definitions start in col 8
-j headwords are set off by colons
-p headwords are preceded by %p, with %d on following line
-i reformat stdin having three-column .index file format
-u <url> URL of site where database was obtained
-s <name> name of the database
--license
-L display copyright and license information
--version
-V display version information
-D debug
--utf8 for creating utf-8 dictionary
--quiet
--silent
-q quiet operation
--help display this help message
--locale <locale> specifies the locale used for sorting.
if no locale is specified, the "C" locale is used.
--allchars all characters (not only alphanumeric and space)
will be used in search if this argument is supplied
--headword-separator <sep> sets headword separator which allows
several words to have the same definition
Example: autumn%%%fall can be used
if '--headword-separator %%%' is supplied
--index-data-separator <sep> sets index/data separator which allows
to explicitly set fourth column in .index file,
the default is "\034"
--break-headwords multiple headwords will be written on separate lines
in the .dict file. For use with '--headword-separator.
--index-keep-orig fourth column in .index file stores original headword
which is returned by MATCH command
--case-sensitive Create .index/.dict files for case sensitive search
--without-headword headwords will not be copied to .dict file
--without-header header will not be copied to DB info entry
--without-url URL will not be copied to DB info entry
--without-time time of creation will not be copied to DB info entry
--without-info DB info entry will not be created.
This may be useful if 00-database-info headword
is expected from stdin (dictunformat outputs it).
--columns Set the number of columns for wrapping text
before writing it to .dict file.
If it is zero, wrapping is off.
--default-strategy Sets the default search strategy for the database.
Special entry 00-database-default-strategy is created
for this purpose.
--mime-header Sets MIME header stored in .data file which
prepend definition
when client sent OPTION MIME to `dictd'
--without-ver do not create 00-database-dictfmt-<VER> entry in .index
gawk: cmd. line:25: fatal: cannot open file `en_US.UTF-8' for reading: No such file or directory
Running phase: fixupPhase
shrinking RPATHs of ELF executables and libraries in /nix/store/6bxbdq30953rp0qdjfv2ib7igg0xcsfv-dictd-dbs
checking for references to /build/ in /nix/store/6bxbdq30953rp0qdjfv2ib7igg0xcsfv-dictd-dbs...
patching script interpreter paths in /nix/store/6bxbdq30953rp0qdjfv2ib7igg0xcsfv-dictd-dbs
building '/nix/store/mw3vr5jlaarwxays4krmw5q8y52gkjz7-unit-script-dictd-start.drv'...
building '/nix/store/25zdnz15z515bvh2mfx1cdkgnhay6nwm-users-groups.json.drv'...
building '/nix/store/6viy1ivlb06dylvhx38ry122as6zyrzq-unit-dictd.service.drv'...
building '/nix/store/1ajik25g4fkfkf14pyiqgfra1j37095q-nixos-help.drv'...
building '/nix/store/qbfqrcikfzx5l7myl2y1gcgqa6im4arg-nixos-help.drv'...
building '/nix/store/xc96gc0zz0723bilj3d12y5bc0rf3wqm-system-path.drv'...
warning: collision between `/nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420/share/dictd/locale' and `/nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542/share/dictd/locale'
created 21778 symlinks in user environment
gtk-update-icon-cache: Cache file created successfully.
gtk-update-icon-cache: Cache file created successfully.
building '/nix/store/w33ns84d8mcphabdkj2mmr5jp28izgpc-X-Restart-Triggers-polkit.drv'...
building '/nix/store/4pn1zvj2a9iq4bv27pa090y466srmwpy-dbus-1.drv'...
building '/nix/store/p4mc4n4im97as0hj2lppmcspgvdvjl1k-etc-pam-environment.drv'...
building '/nix/store/1191gv1xs25dxpg3qdc73j901hxmc6cr-set-environment.drv'...
building '/nix/store/v5phmvl2cfk29wkm0k2ginhrlgvf2ms4-unit-accounts-daemon.service.drv'...
building '/nix/store/h2dq63h0cz1xvk64cyjnp5p2mkrm5czi-X-Restart-Triggers-dbus.drv'...
building '/nix/store/qf62v7kyjkxsnhllyimi1mmrv3lw7snj-etc-profile.drv'...
building '/nix/store/8dd0qivr780p69hip93i8snd04m7pm4r-unit-polkit.service.drv'...
building '/nix/store/mzr1rwpxf91m7s3pyb478mbawvv2z0iw-unit-dbus.service.drv'...
building '/nix/store/ws1calscxya5mvhpp33i258aavsmqs0q-unit-dbus.service.drv'...
building '/nix/store/9qxkdsya1m0m1pmzkf09rjk21dg9kx7p-user-units.drv'...
building '/nix/store/pmv4vsprmr712p19c8qzsk3fif5s8x7c-system-units.drv'...
building '/nix/store/l1dmjv3s5d2vq5q4iqdp60g0gh9sci3q-etc.drv'...
building '/nix/store/hkglharh9ngwz290jy69lan3j9205hjz-nixos-system-laptop-24.05.git.bd645e8668ecM.drv'...
stopping the following units: accounts-daemon.service
activating the configuration...
setting up /etc...
reloading user units for qsu...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service
the following new units were started: dictd.service
apply my tiny patch now..
$ git checkout -- .
$ git st
HEAD detached at bd645e8668ec
nothing to commit, working tree clean
$ git stash pop
Auto-merging pkgs/servers/dict/dictd-db-collector.nix
HEAD detached at bd645e8668ec
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: pkgs/servers/dict/dictd-db-collector.nix
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (b86af5f7b9d3878d6e07041a95a5d7ec3adc5fc3)
$ git diff
diff --git a/pkgs/servers/dict/dictd-db-collector.nix b/pkgs/servers/dict/dictd-db-collector.nix
index 793cbf66a46d..f7d240d46cda 100644
--- a/pkgs/servers/dict/dictd-db-collector.nix
+++ b/pkgs/servers/dict/dictd-db-collector.nix
@@ -43,42 +43,42 @@ let
echo "Directory reference: $j"
i=$(ls "$j""/"*.index)
i="''${i%.index}";
else
i="$j";
fi
echo "Basename is $i"
locale=$(cat "$(dirname "$i")"/locale)
base="$(basename "$i")"
echo "Locale is $locale"
export LC_ALL=$locale
export LANG=$locale
if test -e "$i".dict.dz; then
ln -s "$i".dict.dz
else
cp "$i".dict .
source_date=$(date --utc --date=@$SOURCE_DATE_EPOCH "+%F %T")
faketime -f "$source_date" dictzip "$base".dict
fi
ln -s "$i".index .
- dictfmt_index2word --locale $locale < "$base".index > "$base".word || true
- dictfmt_index2suffix --locale $locale < "$base".index > "$base".suffix || true
+ dictfmt_index2word --locale="$locale" < "$base".index > "$base".word || true
+ dictfmt_index2suffix --locale="$locale" < "$base".index > "$base".suffix || true
echo "database $name {" >> dictd.conf
echo " data $out/share/dictd/$base.dict.dz" >> dictd.conf
echo " index $out/share/dictd/$base.index" >> dictd.conf
echo " index_word $out/share/dictd/$base.word" >> dictd.conf
echo " index_suffix $out/share/dictd/$base.suffix" >> dictd.conf
echo "}" >> dictd.conf
done
'';
in
stdenv.mkDerivation {
name = "dictd-dbs";
nativeBuildInputs = [ libfaketime ];
buildInputs = [ dict ];
dontUnpack = true;
inherit installPhase;
SUCCESS! re-running `test` now against local (above) patch
$ sudo nixos-rebuild --show-trace test -I nixpkgs=~qsu/src/nixpkgs
building Nix...
building the system configuration...
these 7 derivations will be built:
/nix/store/iqf6hic10jmvng9xrkzirdbrrbabahgh-dictd-dbs.drv
/nix/store/5n9awvasz5zr1i80zzg7iv7pv1x6glw9-users-groups.json.drv
/nix/store/rjpm1qic6ng06a5f00l9hlgwsvyy8qhw-unit-script-dictd-start.drv
/nix/store/dfhq0c1y1bdd765y77q7d005jkhbwi2a-unit-dictd.service.drv
/nix/store/sys7sjlfxk6k20b31kcr9dn2vx8x41xf-system-units.drv
/nix/store/zc0v68hnnihrpnj8prcivgjs41kv3va3-etc.drv
/nix/store/ypv410pgyqjjfipcvv8681y3v9814xhr-nixos-system-laptop-24.05.git.bd645e8668ecM.drv
building '/nix/store/iqf6hic10jmvng9xrkzirdbrrbabahgh-dictd-dbs.drv'...
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
Got store path /nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420
Directory reference: /nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420/share/dictd
Basename is /nix/store/mp30f63jvfccjvbn2azj75k92wv8gshw-dict-db-wiktionary-20220420/share/dictd/wiktionary-en
Locale is en_US.UTF-8
/nix/store/d4jf1cbbk494zwgbqz31pxgigpsbh6w2-stdenv-linux/setup: line 1583: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
invalid locale 'en_US.UTF-8'
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
invalid locale 'en_US.UTF-8'
Got store path /nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542
Directory reference: /nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542/share/dictd
Basename is /nix/store/v9y39nqzxj5r5cn306brgzh3gqik6lfr-dict-db-wordnet-542/share/dictd/wn
Locale is en_US.UTF-8
/nix/store/d4jf1cbbk494zwgbqz31pxgigpsbh6w2-stdenv-linux/setup: line 1583: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
invalid locale 'en_US.UTF-8'
/nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
invalid locale 'en_US.UTF-8'
Running phase: fixupPhase
shrinking RPATHs of ELF executables and libraries in /nix/store/n1ibh8rd3n484sg7ln58a9b15vb1f76d-dictd-dbs
checking for references to /build/ in /nix/store/n1ibh8rd3n484sg7ln58a9b15vb1f76d-dictd-dbs...
patching script interpreter paths in /nix/store/n1ibh8rd3n484sg7ln58a9b15vb1f76d-dictd-dbs
building '/nix/store/rjpm1qic6ng06a5f00l9hlgwsvyy8qhw-unit-script-dictd-start.drv'...
building '/nix/store/5n9awvasz5zr1i80zzg7iv7pv1x6glw9-users-groups.json.drv'...
building '/nix/store/dfhq0c1y1bdd765y77q7d005jkhbwi2a-unit-dictd.service.drv'...
building '/nix/store/sys7sjlfxk6k20b31kcr9dn2vx8x41xf-system-units.drv'...
building '/nix/store/zc0v68hnnihrpnj8prcivgjs41kv3va3-etc.drv'...
building '/nix/store/ypv410pgyqjjfipcvv8681y3v9814xhr-nixos-system-laptop-24.05.git.bd645e8668ecM.drv'...
stopping the following units: dictd.service
activating the configuration...
setting up /etc...
reloading user units for qsu...
setting up tmpfiles
starting the following units: dictd.service
Ah yeah. I think I’d already gotten offline dictionary look-ups working (networkless dict "encyclopedia" indeed works without this patch), and that locale issue was just a red herring. I was definitely unsure about it being a red herring for quite a while… so just had this rattling on my radar to revisit.
That link to the doc is super helpful. I still find this entire overrideAttrs oneliner to be a bit of black-magic though, so I think I have some more nix-language learning to do… I’ll keep reading