{"id":13681432,"url":"https://github.com/pmiddend/nixos-manager","last_synced_at":"2025-05-12T22:45:14.703Z","repository":{"id":63116078,"uuid":"246862016","full_name":"pmiddend/nixos-manager","owner":"pmiddend","description":"Manage your NixOS packages and configuration via a simple, intuitive UI","archived":false,"fork":false,"pushed_at":"2020-05-02T06:04:27.000Z","size":1957,"stargazers_count":181,"open_issues_count":8,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-12T22:44:49.070Z","etag":null,"topics":["declarative","haskell","nix","nixos","ui"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmiddend.png","metadata":{"files":{"readme":"Readme.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-12T14:58:18.000Z","updated_at":"2025-04-24T12:04:32.000Z","dependencies_parsed_at":"2022-11-13T05:02:45.758Z","dependency_job_id":null,"html_url":"https://github.com/pmiddend/nixos-manager","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmiddend%2Fnixos-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmiddend%2Fnixos-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmiddend%2Fnixos-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmiddend%2Fnixos-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmiddend","download_url":"https://codeload.github.com/pmiddend/nixos-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253837387,"owners_count":21971981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["declarative","haskell","nix","nixos","ui"],"created_at":"2024-08-02T13:01:30.661Z","updated_at":"2025-05-12T22:45:14.645Z","avatar_url":"https://github.com/pmiddend.png","language":"Haskell","funding_links":["https://paypal.me/PhilippMiddendorf"],"categories":["Haskell"],"sub_categories":[],"readme":"* nixos-manager — manage your NixOS graphically\n\n[[https://www.gnu.org/licenses/gpl-3.0][https://img.shields.io/badge/License-GPLv3-blue.svg]] [[https://travis-ci.com/pmiddend/nixos-manager.svg?branch=master][https://travis-ci.com/pmiddend/nixos-manager.svg?branch=master]]\n\n** Rationale\n\nThe idea is to build something to *configure NixOS graphically*. To me, this means: managing the installed software packages, and managing the enabled services, as well as updating and garbage-collecting. For the moment, I’m focusing on a solution for a declarative, global configuration; so /for the moment/ it’s not calling =nix-env= and it’s not supporting =home-manager=.\n\nThe goal is *not* to make all of NixOS accessible via a GUI, and not give an alternative to writing Nix expressions for your configuration. Instead, this is a project to explore how far you can get graphically after installing NixOS (which — in the future — might be possible via a GUI installer as well).\n\n** Approach\n\nSince the NixOS configuration is very “free-form”, I have to make some assumptions about the structure of your =configuration.nix= file, as such:\n\n- You have two additional =.nix= files, referenced from the =imports= section in your =configuration.nix=: =packages.nix= and =services.nix=\n- =packages.nix= is a flat list of packages\n- =services.nix= is a list of service options, like ~services.xserver.enable = true~.\n\nIn nixos-manager, you can mark packages for installation. They will be added to your /local/ copy of =packages.nix=. You can then trigger a nixos-rebuild from inside nixos-manager, which copies your local installation to the /global installation/ inside =/etc/nixos/nixos-manager/packages.nix=. Same for configuring services and =services.nix=.\n\nTo gather service definitions, nixos-manager downloads and parses https://nixos.org/nixos/options.json. This way, the service definitions might not accurately reflect your system configuration, but I just found no other way to gather the definitions, see [[https://discourse.nixos.org/t/list-available-services-and-their-options/][this Discourse thread]].\n\n** Screenshots\n*** Welcome screen, featuring a frontend for =nixos-rebuild=\n\n[[./screenshots/admin.png]]\n\n*** Welcome screen for =home-manager= users\n\n[[./screenshots/home-manager.png]]\n\n*** Search and install (or try) packages\n\n[[./screenshots/packages.png]]\n\n*** Configure services\n\n[[./screenshots/services.png]]\n** Screencast\n\n[[https://www.youtube.com/watch?v=Fa4_9ueOdpY\u0026feature=youtu.be][Watch on YouTube]]\n\nPlease recommend to me another platform where I can upload this, preferably lossless as the source mkv that I have.\n\n** FAQ\n*** Have you seen [[https://github.com/haskell-nix/hnix][hnix]]? Why don’t you parse your you Nix files with\n\nI’d love to! But sadly and ironically, it’s currently [[https://github.com/NixOS/nixpkgs/issues/82233][broken]] in nixpkgs. I’m waiting for someone to repair it, as I don’t have the knowledge to do that.\n\nI’m using Haskell as the language of choice, simply because =hnix= is available and allows me to easily parse and serialize the relevant Nix configuration files. The GUI is made via =gi-gtk-declarative=, which serves me well and is pretty stable.\n\n*** Can I configure NixOS using this tool and manually at the same time?\n\nYes, that’s possible. The files that nixos-manager uses shouldn’t be edited by hand, but you can configure services and packages the regular way as well, by editing =configuration.nix=. Thus, nixos-manager is just an enhancement.\n\n*** The list of packages only lists packages installed by nixos-manager, not globally installed ones. How come?\n\nThe simple reason is: I haven’t gotten to that part yet, and my Nix knowledge is so limited I’d have to ask how do that first.\n\n** Building\n\nnixos-manager isn’t in nixpkgs yet, so you’ll have to build it using…Nix!\n\n#+begin_src bash\nnix-build -I nixpkgs=channel:nixos-unstable\n#+end_src\n\nThe channel argument is necessary in case you’re not on =nixos-unstable=.\n** Setup and running\n*** With home-manager\nAfter building it (see above), you have to tell home-manager to read nixos-manager’s configuration files. To do that, open your =~/.config/nixpkgs/home.nix= file and insert the following somewhere inside the main attribute set:\n\n#+begin_example\nimports = [ ./hm-extra-services.nix ./hm-extra-packages.nix ];\n\nmanual.json.enable = true;\n#+end_example\n\nnixos-manager, when run in home-manager mode, will write these extra files. The second line enables JSON export of the available options in home-manager, which nixos-manager reads to generate the configuration UI.\n\nTo run nixos-manager in home-manager mode, simply run it with the =--home-manager= argument. For example, if you built it with Nix, run:\n\n#+begin_example\nresult/bin/nixos-manager --home-manager\n#+end_example\n\nIf you’ve built it with =cabal= (for example, to try it out after changing the code), run:\n\n#+begin_example\ncabal v2-run nixos-manager -- --home-manager\n#+end_example\n\n*** With NixOS\nAfter building it (see above), you have to tell NixOS to read nixos-manager’s configuration files. To do that, open your =/etc/nixos/configuration.nix= file and look for a line containing ~imports = …~. Usually it looks something like this:\n\n#+begin_src nix\n{\n  # …\n  imports =\n    [ # Include the results of the hardware scan.\n      ./hardware-configuration.nix\n    ];\n  # …\n}\n#+end_src\n\nSo =imports= contains an array of Nix files. You can extend this array by just listing more files, separated by spaces. To use NixOS manager, extend the list as such:\n\n#+begin_src nix\n{\n  # …\n  imports =\n    [ # Include the results of the hardware scan.\n      ./hardware-configuration.nix\n      ./nixos-manager/services.nix\n      ./nixos-manager/packages.nix\n    ];\n  # …\n}\n#+end_src\n\nnixos-manager will create these two files when you apply changes.\n\n** Current status\n\n- The frontend for =nixos-rebuild= works. It supports =--upgrade= and =--rollback=.\n- =nix-collect-garbage= is also supported, supporting the =-d= flag.\n- Rebuilding copies =packages.nix= and =services.nix= to =/etc/nixos/nixos-manager=. Without these files being included in your =configuration.nix=, they’re worthless, though.\n- Configuring services works, with some minor quirks.\n- Trying packages works, and installing/uninstalling too. The =packages.nix= will be updated accordingly.\n** Contributing guide\n*** Prerequisites\n\n- nixos-manager is written in [[https://www.haskell.org/][the Haskell Language]]. You should be proficient with this language. I can’t give a full recommendation list for learning it (can anyone reading this?). It’s /really/ worth it though. Some books are\n  - [[http://book.realworldhaskell.org/][Real World Haskell]] (free)\n  - [[http://learnyouahaskell.com/][Learn You a Haskell for Great Good!]] (free)\n  - [[https://www.amazon.com/Programming-Haskell-Graham-Hutton/dp/1316626229/ref=sr_1_1?dchild=1\u0026keywords=haskell\u0026qid=1585907775\u0026sr=8-1][Programming in Haskell: Hutton, Graham (Amazon-Link)]]\n  - [[https://haskellbook.com/][Haskell Programming from first principles]]\n- I’m using [[https://www.gtk.org/][the GTK toolkit]] and specifically [[https://owickstrom.github.io/gi-gtk-declarative/][gi-gtk-declarative]] as a declarative approach to writing GTK applications. The documentation is [[https://owickstrom.github.io/gi-gtk-declarative/widgets/the-widget-type/][here]]. A good blog post by the author is [[https://wickstrom.tech/programming/2018/09/04/declarative-gtk-programming-with-haskell.html][Declarative GTK+ Programming with Haskell]].\n*** Code structure\n\nEach module has haddock documentation. Finding information about the code just from that might be difficult though, so let me give you a short overview:\n\n- Each of the tabs you see (notebook pages, in GTK-Speak) has a submodule. There’s =NixManager.Admin=, =NixManager.Services= and =NixManager.Packages=, respectively.\n- Inside each such submodule you have modules =Event=, =Update= and =View=.\n  - =Event= contains the even data type for the submodule (which is then embedded in =NixManager.ManagerEvent=)\n  - =Update= contains the update handler (a function receiving the current state and an event and returns a new state, as well as an event and IO side-effects)\n  - =View= contains the =gi-gtk-declarative= classes for the notebook page.\n  - =State= contains the state corresponding to the subsystem\n- When starting a process, such as the rebuild process, we cannot easily run it in the background and emit an event when it’s finished (at least I don’t know how to do that comfortably with =gi-gtk-declarative-app-simple=). Instead, we are spawning the process (in the background, mind you), then wait for a small amount of time (which doesn’t block the GUI, fortunately) and then emit a “watch” event, which does the same thing, until the process signals completion. It sounds hacky, and it is, but it’s not that bad.\n** Alternatives\n\n- [[https://gitlab.com/juliendehos/nix42b][nix42b]] — is another user-friendly Nix package manager, also written in Haskell. It doesn’t seem to be actively maintained anymore.\n** Donations\n\n[[https://paypal.me/PhilippMiddendorf][PayPal.Me]]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmiddend%2Fnixos-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmiddend%2Fnixos-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmiddend%2Fnixos-manager/lists"}