The 02/08/2015 12:21, Jeffrey David Johnson wrote: > Nice! I'm currently binding "gksu 'i3lock -c000000 & > pm-suspend'" to a hotkey using i3, but this is better. Is > there a standard way to get it in my fork of nixpkgs, which is > tracking the release-14.12 branch? (I could just copy and > paste but if there's a better way now would be a good time to > learn.)
I certainly don't have an authoritative answer to this question, but I'll tell you what I am doing and then maybe someone with much more NixOS/Nixpkgs experience will chime in with tweaks/guidance. In general I have the following goals for my NixOS system: 1. I want everything to be reproducible, which of course means that my system is configured in /etc/nixos/configuration.nix, but also that any packages that I install as an individual user are reproducible as well. 2. Related to the above, I only want to put "system" packages into configuration.nix. My theory here is that most of my package management is going to be done as a regular user, by creating project-specific nix-shell environments, etc. Also, `nix-env -q` is a nice way to see everything that is installed and it doesn't appear that similar tools exist at the NixOS level. Goal #1 means that configuration.nix is pretty basic -- the bare minimum number of packages to get my system working and launch an X environment (the window manager, for example, but no apps). Goal #2 was more complex. I found the following two references on this topic: - <https://nixos.org/wiki/FAQ#How_can_I_manage_software_with_nix-env_like_with_configuration.nix.3F> - <https://nixos.org/wiki/Howto_keep_multiple_packages_up_to_date_at_once> I went with the first option because I wanted to be able to use `nix-env -q` to see what I had installed, regardless of how I did the install (manually or through the "myPackageSelections.nix" file). I can provide more details here if you like. With that choice out of the way, the next problem that I ran into was getting access to newer packages. I have contributed a couple of packages to Nixpkgs, fixed some others, etc. and so far I had just been manually installing them out of my nixpkgs checkout. This was not entirely compatible with my first goal, because now I had installed packages that were not listed in my configuration. Enter the nixpkgs-unstable channel! That channel seems to be updated pretty frequently and means that changes are available in binary form within a few days. Thankfully my second goal meant that I already had a perfect split between stable and unstable: my NixOS configuration could stay on 14.12 and my user-level Nixpkgs was free to go unstable. Getting this working was relatively straightforward, although I had to modify my environment in a couple of unexpected ways (more on this later). The simple part is the `nix-channel --add https://nixos.org/channels/nixpkgs-unstable` and `nix-channel --update` as a normal user. Some things worked after that, but not everything. `nix-env -i whatever` will happily use the nixpkgs-unstable channel because it finds that channel in ~/.nix-defexpr. Adding in the -f flag to specify your own expression means that nix-env no longer knows about the channel though. Instead, nix-env falls back to NIX_PATH, which by default points at the stable NixOS channel and therefore has no idea that you want to use nixpkgs-unstable. I found that very confusing, although that's probably because of the subtlety that is the myPackageSelections.nix-based way of managing my package list. In any event, I had to dig through the docs to understand the situation. I fixed this problem by setting NIX_PATH to `nixpkgs=~/.nix-defexpr/channels/nixpkgs` and removing the channels_root symlink from ~/nix-defexpr. That last step probably isn't necessary, but every now and then nix-env would complain about duplicate packages and besides that I don't want to get (user) packages out of the stable NixOS channel anyway. This all seems to work pretty well and lets me have fast access to new/changed packages without compiling everything myself. I am a bit worried that changing NIX_PATH and removing channels_root is going to cause me trouble one day, but so far everything seems fine. As I said, I would welcome input here from the NixOS/Nixpkgs experts. I am curious to see what folks think about my installation approach as well. I feel like this split between stable OS and unstable packages is a good one and that declarative user-level package management is also valuable. That said, NixOS doesn't support either one "out of the box" so I am wondering if there is a better approach that I should be using. Hope that helps! Thanks, Michael Alyn Miller _______________________________________________ nix-dev mailing list [email protected] http://lists.science.uu.nl/mailman/listinfo/nix-dev
