Why the overlay? If you just want to give the drvs names (good practice IMO), simply use a let binding.
The buildEnv is unnecessary: systemPackages does the same with all the derivations in the list in the end anyways.
All about NixOS - https://nixos.org/
Why the overlay? If you just want to give the drvs names (good practice IMO), simply use a let binding.
The buildEnv is unnecessary: systemPackages does the same with all the derivations in the list in the end anyways.
If you just want to give the drvs names [...], simply use a let binding.
I must be missing something here.. my first idea was to put all the writeShellApplication
s inside systemPackages
(with no let bindings: the scripts are generated from config anyway), but it resulted in nixos complaining that it was expecting actual packages.
Edit: scratch that - I was being stupid :)
There's probably a cleaner way to do this, but you can look at abstractions as a way to reduce all that code repetiton.
Don't worry about the extra derivations. Nix is full of them.
Well, it does work as-is, and it's not like I'm worried how many symlinks need to be dereerenced... the point is mainly that my nix code could be much simpler if I didn't have to build the overlay attrset like that from a list.
You might simplify it a bit with something like,
let my-hello-scripts = [
(writeShellApplication {
name = "my-hello-1-script";
text = "echo my hello world 1";
})
(writeShellApplication {
name = "my-hello-2-script";
text = "echo my hello world 2";
})
];
in
{
environment.systemPackages =
my-hello-scripts ++
[ pkgs.whatever-else-you-want ];
}
That was my first idea (well, I say "my"... but it was really suggested by yourself in the question I posted the other day), but it results in nixos complaining that error: A definition for option 'environment.systemPackages."[definition 1-entry 1]"' is not of type 'package'.
It might very well be that I'm doing some stupid mistake here (or maybe it's something that used to work and doesn't anymore?)... here's what I used to test it out:
environment.systemPackages = [
pkgs.writeShellApplication {
name = "some-script";
text = "echo hello wolrd";
}
];
Edit:
And indeed I was the one doing stupid things: it must be
environment.systemPackages = [
(pkgs.writeShellApplication {
name = "some-script";
text = "echo hello wolrd";
})
];
with the parentheses, or it's a list with two elements (a function and an attrset)...