Can I use NixOS without being able to code?

Not sure why I need options here, I didn’t understand, what I meant is that I plan adding that line to the beginning of every .nix file I created, so even though { pkgs, ... }: should suffice for installing an app, I can add everything like { config, pkgs, options, ... }: at the beginning of each file with just one terminal command so that if I need to add an option or a config to that file in the future, the attribute will be already declared.

i don’t believe you can do that in any meaningful way, however, you can learn nixos without any prior programming knowledge: nixos has its own language which is not very hard to learn. the docs aren’t very beginner friendly so i wrote my own docs when i learned nix, maybe they help you: https://github.com/bugsbugsbux/notes-on-nix

1 Like

Cool idea, thank you for it

@waffle8946 @srd424 @rnhmjoj
I managed to fix all the files in the end, the build begins, but after a while the GUI crashes and it goes into emergency mode, I’m asked to enter root password to work in emergency mode or reboot, which leads to an unbootable system. How do I diagnose something like that?

the boot-manager should give you the option to boot into an earlier generation, which should allow you to boot into the system and remove the broken generation. then try to fix the config (use a language server for useful tips: https://github.com/oxalica/nil) and rebuild using a different command then nixos-rebuild switch to avoid crashing your system again due to a broken system being activated. see: nixos-rebuild --help

1 Like

Thank you, I will try to rebuild adding only nil and then perform a sudo nixos-rebuild boot, hopefully that will show the issue.

Not options, options! Please click the link I posted.

1 Like

I hit that sometimes if my filesystem mounts are incorrect - worth checking the journal for errors.

1 Like

I really don’t think requires that at all. Even if you end up writing some actual library functions, the real programming has already been done for you in the nixpkgs lib. You won’t be writing any actual algorithms as a NixOS user.

The thing that is a little confusing at first is primarily the NixOS module system, which is completely separate from nix, and has little to do with functional programming. It’s also not covered in any of the nix tutorials, which doesn’t exactly help newcomers.

But even in spite of that, I think basic configs are not hard to understand from a “programming” perspective, if you’re comfortable editing config files (which can be a high bar to pass among general users), NixOS is not a far step up.


That said, NixOS is actually quite a paradigm shift for distro config, and requires thinking very differently from other distros - often even for everyday use (loads of people are apparently used to just manually modifying files in /usr on other distros…).

I think most of the issue with NixOS adoption does not come from the complexity of nix, but from the clash of overwhelmingly imperative-first software being used by users used to imperative systems in an environment that approaches being fully declarative. Even the choice of software (e.g. GNOME vs sway) will change the difficulties you run into a lot.

If that makes no sense to you, give it a year or two, you’ll understand what I mean x)


As for my 2c on how to get started, I concur with @rnhmjoj - start with a simple config, keeping everything in one configuration.nix for the first few months.

You can go more complex (I do), but if you start out that way before thoroughly understanding the module system and your actual use case you’ll just make a mess (I did, and haven’t fully cleaned it up even to this day). It also makes it harder to share your config when you ask for help if it’s split into loads of files without much understanding. Give it time to grow structure naturally and then split stuff, and then maybe rethink a design from scratch.

I’d also stay far, far away from complex configs without git, if you want to go down that route, learn git first (particularly, you should at least understand rebasing to change history, working with feature branches, and the purpose and how to do bisecting as second nature, and also have an editor/IDE set up to help you track changes in your worktree - it’s hard to keep on top of stuff otherwise).

1 Like

Yes, I did, but I didn’t understand. Do you mean I should use programs.thunderbird.enable = true instead of adding the package? Does it make a difference?

Yes. The options will add other configuration that is necessary for the package to properly run. Always check if there’s an option to enable before manually adding the package - the option will also add the package to the list behind the scenes.

In the case of thunderbird, it just disables auto updates, but that’s important because you need to do those with nix: nixpkgs/nixos/modules/programs/thunderbird.nix at 314e12ba369ccdb9b352a4db26ff419f7c49fa84 · NixOS/nixpkgs · GitHub

2 Likes

I see, I was using options for stuff like ssh, but I didn’t think even GUI apps would need them, makes sense though, I guess I always took advantage of these modifications but they were transparent to me, being done by the distro’s package maintainers for example.

Still, there’s stuff seriously lacking options, for example there are a lot of options for i2pd, but for i2p there’s only the option to enable it. On imperative systems the config is scattered across several files like
/var/lib/i2p/i2p-config/router.config
/etc/default/i2p
/etc/i2p/wrapper.config
declarative configuration would be perfect for such software, unfortunately I have no idea how to declare such configuration in NixOS, it is undocumented.

Well, the package maintainers do the same thing here, they’re the ones writing the modules.

The difference is that because things are not in traditional FHS paths, and packages are confined to /nix/store instead of being allowed to litter all over your system, additional config is often needed to get applications to read config from non-standard locations. This often has to be done via options because it requires writing environment variables, or /etc, which you cannot do with a package on NixOS; only your config has that privilege (through the activation script, which in turn is in the store).

Yep, especially for desktop oriented stuff you won’t see too many options. home-manager often has more for desktop users. You can still add this manually quite easily by creating your own systemd service, or changing the default settings of the systemd service.

That said, I’m not sure i2p specifically can be configured reasonably, it looks to be one of those java applications. See my point about overwhelmingly imperative software…

Having looked at the source, I think that you need to put those files in /var/lib/i2p, but the module looks largely abandoned. If you know i2p well, this is where you’d need to start helping upstream.

1 Like

I tried to rebuild using the original configuration.nix file I backed up, adding only nil, but every time it fails to rebuild. I even removed nil and it still fails.
This is the output of the command:

error:
       … while evaluating the attribute 'config'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12284:
       … while calling the 'seq' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12293:
       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: module /etc/nixos/configuration.nix (/etc/nixos/configuration.nix:anon-1) does not look like a module.
building Nix...
error:
       … while evaluating the attribute 'config'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12284:
       … while calling the 'seq' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12293:
       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: module /etc/nixos/configuration.nix (/etc/nixos/configuration.nix:anon-1) does not look like a module.
building the system configuration...
error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12284:
       … while calling the 'seq' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12293:
       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: module /etc/nixos/configuration.nix (/etc/nixos/configuration.nix:anon-1) does not look like a module.

This is with the original configuration.nix file as it was generated by the GUI installer, it can’t possibly have a wrong syntax. How can it be?

Post what you have. We don’t know what you have unless you share it with us

I assume from the stack trace that it’s trying to tell us, that an imported file is bad (/etc/nixos/configuration.nix:anon-1)

I would look either at the second imported file (assuming that it starts with 0).

Aside that what waffle wrote.

I’m an idiot, that was a subsequent generation. The original file worked.

All the failed attempt at building created their generations.
I tried to run sudo nix-collect-garbage -d from the first generation, but all the subsequent ones were not deleted, I guess it deletes only generations previous to the one in use?

Anyway I enabled nil and tried sudo nixos-rebuild boot and to my surprise it worked. I then tried sudo nixos-rebuild switch and that worked too. I thought both commands silently failed because they took seconds to run, but I think it’s because previous attempts already downloaded all the packages in the Nix store, right?

I don’t recall changing something significant within the configuration, but for some reason now it works, now I have a usable system (at least I hope, I must still begin to use it).

I don’t know how to thank all of you, yesterday I was about to give up, now I have a working system and the most difficult part seems to be behind, I’m very grateful to all of you for your precious help and encouragement.

One thing I’m having issues with is the Tor browser, I always downloaded the archive from the Tor Project’s website and launched the executable file (I know it’s in the repos, but I’d rather keep using it like that). So every time I wanted to use it on another system I simply copied its folder and launched it, but this doesn’t work in NixOS, is it normal?

yes, that’s to be expected since nixos does not follow FHS. try it after adding this to your config:


    # run unpatched linux executables
    programs.nix-ld = {
        enable = true;
        # put necessary libraries here:
        #libraries = with pkgs; [];
    };

and seriously, read my notes, they assume you don’t know anything

1 Like

Thank you, by looking at what you wrote I also need libraries? What libraries are necessary?

not necessarily, it might just work, however, if there is something missing it won’t and then you have to figure which library is the missing one and add it there

1 Like