Nixos-manager — manage your NixOS configuration graphically

I would like to announce nixos-manager, which is my attempt at a GUI to manage your NixOS configuration. The GitHub page contains more information about it, be sure to check it out. I’ve also recorded a short Screencast (link goes to YouTube) which introduces all the features currently present.



Description

The idea was to provide a tool that, once NixOS has been installed, could be used to graphically install packages and configure the system. The cool thing with NixOS is, most service options have a type attached to them. Using these types and the nested set structure of the NixOS configuration, one can transform service definitions into editable GUIs. Service meaning “prefix is services., programs., …” and so on.

Aside from that, I included search and installation/removal of packages, as well as a frontend for nixos-rebuild and nix-collect-garbage, so hopefully, one can finish day-to-day tasks on NixOS without opening a terminal.

Note that the idea is specifically not to offer an alternative to configuring NixOS, but really just a supplement. I cannot fathom an easy-to-use GUI for writing Nix expressions. That’s something for a text editor, really.

Technically, all the tool does is write two .nix files to your $HOME, one for services and one for programs. Prior to calling nixos-rebuild, it copies these files to /etc/nixos/nixos-manager, so if you include these two files in your configuration.nix, nixos-manager is usable.

Current state, further work

nixos-manager is just a hobby project I’m working on during my time between jobs, and I plan to continue working on it for some time. I encourage contributions from other users, though the project is written in Haskell, so you have to be somewhat proficient with that language, I suppose (not that I am an expert in it).

There are some technical hoops I had to jump through, possibly because I’m not the most experienced Nix user. For example, I couldn’t find a way to enumerate all service definitions in a machine-readable format (relevant Discourse question) — other than to download the JSON file from the nixos.org site. Also, I’d have loved to include more meta information about the packages (and services), like the URL or license.

The service configuration GUI is also pretty basic right now, not a lot of widgets exist. I wanted to gauge interest in this first, and then improve on it further.

Let me know what you think!

55 Likes

This is awesome. thanks for all the work so far!

Hey, as someone who is still learning Nixos, i wanted to install this, but failed. Maybe you can tell me why. I cloned the repo, and did nix-build. It started to build a whole lot of haskell stuff, i am not quite sure why it did not get the binarys, maybe something with overrides of package definitions? It failed on

src/Codec/Crypto/RSA/Pure.hs:115:25: error:
    • Could not deduce (MonadFail m) arising from a use of ‘fail’
      from the context: (Monad m, Show a)

Is this a bug in some haskell RSA implementation?

This is nixos 20.03, 19.09 didn’t work because of ghc833 specified in build.nix

The build: build.log - Pastebin.com
(log of second try, on the first it build stuff for some hours before failing)

If someone knows whats going on, i would be happy to learn something here

This probably doesn’t work partly due to a lack of experience with Nix from my side. In the default.nix, I just use import <nixpkgs> {} to get the program dependencies, assuming you have “the right version” of nixpkgs. I can assure you that this probably works when you’re on the nixos-unstable channel, since that’s what Travis CI uses to build the program.
If you build the software inside nix-shell (so nix-shell --run "cabal v2-build"), this should work as well, because for the shell, I have the dependencies pinned.
Maybe I should pin the dependencies for default.nix, too, but I have to do it in a way so that Travis doesn’t build any dependencies (since there’s a time limit). Not sure what the best solution is here.

In GitHub - ryantm/nixpkgs-update: Updating nixpkgs packages since 2018 (also Haskell), I use Cachix to make the CI fast and to distribute binaries. niv is used for pinning nixpkgs.

2 Likes

A recent version of GHC removed fail from the Monad class and moved it to MonadFail. Sounds like someone just needs to update the code to account for this change.

It worked with

 nix-build -I nixpkgs=channel:nixos-unstable

Looks very nice, i’ll do some experiments with it

Thanks for this great project !
I’ve added a link to it in the readme of nix42b.

1 Like

Thanks! I hope I wasn’t too forward in assuming nix42b isn’t maintained (actively) anymore. I’d be happy to correct the statement if it’s untrue! :slight_smile:

Thanks for letting me know. I’ve updated the readme using this build statement, so people have less problems building.

You can also skip cloning the repo manually with nix-env -i -f https://github.com/pmiddend/nixos-manager/tarball/master. I’m not sure if several -f arguments work for a -f channel:nixpkgs-unstable but you could also just use the -I argument, like caaaaaa did, here (and that argument is repeatable fwiw).

I’ve been picturing something like this for quite a while now. Thank you!!!

I am excited to see how this might work with configs like mine in the future, but am very glad to see something as a starting point!

Build failed anyway for me:

$ nix-build -I nixpkgs=channel:nixos-unstable
...
[2 of 2] Compiling Codec.Compression.Brotli ( src/Codec/Compression/Brotli.hs, dist/build/Codec/Compression/Brotli.o )
copying path '/nix/store/j1j55xflgsg8vix23zvccgblqqpw1sim-gi-atk-2.0.21' from 'https://cache.nixos.org'...
copying path '/nix/store/63g28ahk7jx1hbigd42v322sjvdj1bgq-gi-gio-2.0.26' from 'https://cache.nixos.org'...
Using Parsec parser
Configuring butcher-1.3.3.0...
CallStack (from HasCallStack):
  die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:1022:20 in Cabal-3.0.1.0:Distribution.Simple.Configure
  configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:475:12 in Cabal-3.0.1.0:Distribution.Simple.Configure
  configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:625:20 in Cabal-3.0.1.0:Distribution.Simple
  confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:65:5 in Cabal-3.0.1.0:Distribution.Simple.UserHooks
  configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:180:19 in Cabal-3.0.1.0:Distribution.Simple
  defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:116:27 in Cabal-3.0.1.0:Distribution.Simple
  defaultMain, called at Setup.hs:2:8 in main:Main
Setup: Encountered missing or private dependencies:
base <0 && <999

builder for '/nix/store/7q09dgvlqwv122vjfclwnzlpa673d1q5-butcher-1.3.3.0.drv' failed with exit code 1
cannot build derivation '/nix/store/hd2g3gmx3raca928gi4dg11477yh54v1-brittany-0.12.1.1.drv': 1 dependencies couldn't be built
copying path '/nix/store/3fqkxzj8qbrp5vxj7679khk9fi1mg30i-gi-pango-1.0.22' from 'https://cache.nixos.org'...
cannot build derivation '/nix/store/na9irj2j54kbyvka77vaxqf01vsm1xky-ghc-shell-for-nixos-manager-1.0-0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/0p1ir9pgdmgq0224pbzp2w8gabig3lxi-nixos-manager-1.0.drv', '/nix/store/na9irj2j54kbyvka77vaxqf01vsm1xky-ghc-shell-for-nixos-manager-1.0-0.drv' failed
1 Like

Thanks for reporting this. It’s an issue in nixpkgs, which I have circumvented now (see haskellPackages.brittany is broken · Issue #85923 · NixOS/nixpkgs · GitHub).

Note also that master currently contains initial support for home-manager, using the --home-manager command line flag. Expect bugs until I’ve released 1.1, however. :slight_smile:

1 Like

Too bad development has stopped for this project. It would’ve been a great to have a graphical means to maintain your environment.

Alas I don’t know Haskell, neither do I have the time to contribute time to this project :pensive: