NixOS

753 readers
3 users here now

NixOS is a Linux distribution built on top of the Nix package manager. Its declarative configuration allows reliable system upgrades via several official channels of stability and size.

This community discusses NixOS, Nix, and everything related.

founded 1 year ago
MODERATORS
26
27
 
 

I want to start a new project, and I want to try to handle all the reproducibility / "containerization" in nix instead of dockerfiles. I see some examples online but I think they're including more uncommon procedures and/or don't do things the "nix" way.

What's the right way to manage a simple python project? Should I just make a derivation.nix for use in nix-shell -p and have the ephemeral shell be my container? Can/should I do it with nix flakes instead? What would a simple nix flake look like that:

pulls an initial python repo from github

possibly executes whatever build instructions might be included

extends other system packages or other versions of the same python package,

has local area network access,

and GPU access

28
 
 

cross-posted from: https://feddit.de/post/7895009

I'm a semi-recent NixOS user and one thing that bothers me since the beginning is that when I change the Gnome theme (between light and dark), Firefox doesn't adapt. The system theme in Firefox is enabled, but it always displays the light theme, no matter what theme is selected in Gnome.

Internet search, including searching through NixOS discourse, packages, options and Nixpkgs repo surfaced a solution.

Any ideas or tips how to achieve system theme integration for Firefox on NixOS?

NixOS 23.11 / Gnome 45 / sway

29
30
 
 

Plenty of nix'd config, nix-colors theming for most applications. I've only been using linux for around 6 months, NixOS has really clicked with me.

My config might be sub-optimal in areas, but its gone through some heavy changes since its inception.

31
 
 

I've probably parsed dozens of pages now, including the "Dual boot NixOS and Windows" page on nixos.wiki, and not really sure what the best steps are since most seem to leverage the fact that everything is on a single partition. My windows lives on a physically separate drive than NixOS, so osprober does not detect the windows partition at all. I tried to go down the route of grub-mkconfig but that doesn't seem to be a nix package and I couldn't mount my Windows bootloader as it is NTFS. Is this even possible with this configuration?

My next step was going to be to physically disconnect each of my disks/NVME, nuke everything bit by bit, then only connect the disks I want and install each OS with it's specific disk connected.

32
 
 

cross-posted from: https://programming.dev/post/7531089

🗓️ Mark your calendars! NixCon North America 2024 is happening on March 14th and 15th in CA, USA. Submit your talk or workshop proposal before December 31, 2023, 11:59 PM PST. Be a part of this exciting event! More details at: https://discourse.nixos.org/t/nixcon-na-2024-call-for-proposals/36491

33
 
 

I see you can delete everything older than some period of time, but what if I want some older than a year? Or should it be interpreted that: whatever build configuration was used, it is tested thoroughly at that point, and it would be better to rebuild from a nix configuration stored on git?

34
 
 

Edit: my issues came from copying source .nix configurations for the pig manager, not configurations that I would include on my computer. Finding how to include what where was much easier with search.nixos.org

Hi, I've finally cleansed my system of windows and switched fully into nix. I want to learn this OS the right way, but have ran into some noob troubles. Any help would be greatly appreciated. Ideally, these changes are things I would include in my configuration.nix

  • How to install electrum wallet on nixos? I found this default.nix for electrum and thought it would be as easy as nix-build default.nix but was mistaken. It says " cannot evaluate a function that has an argument without a value ('fetchurl') Nix attempted to evaluate a function as a top level expression" but on a later line that value is inputted to the function (if I understand right)

src = fetchurl { url = "https://download.electrum.org/${version}/Electrum-${version}.tar.gz"; sha256 = "sha256-BxxC1xVKToUjgBo4mEeK9Tdhbd/+doHcTTJsXDtaELg="; };

  • How to install KVantum Theme Manager? I was following this guide and tried to add gcc/g++ and the x11 package dependencies but I get undefined variables for the x11 libraries. Some recommend using stdenv.mkDerivations but I haven't used that much nix before so I'm not certain if I should be going down that rabbit hole
35
 
 

Came across a new nix wiki attempt. The announcement post is made on discourse with high skepticism.

But I really like it for two reasons:

  • For now, its incredibly informal and the barrier to entry is low. And because I can make edits directly in the web interface, it felt easy to contribute.
  • The creator mentions wanting this to be like the Arch wiki. In other words, contain information useful to nix users, but not necessarily nix specifically.

I was able to contribute a new article about distrobox, a tool I discovered and made a post about here a month or so ago.

Maybe we don't "need" another wiki, but the opportunity to contribute really made this one stand out to me. In case you all might want to contribute or learn something, I thought I would share.

36
 
 

I'm conflicted on what should handle my login manager, desktop environment, and window manager. What are the pros and cons of doing it from a nixos configurations versus a home manager configuration?

37
 
 

I want to use Plasma-manager in my system. I have enabled flakes in configurations. Now what to do to use it. The output generated by tool rc2nix can be copied through terminal but when i put that in home.nix , it says that plasma is not available which is true but then how do I use this tool. flake file.

38
39
 
 

I've made a fun little project inspired by this (except it's not updated any more).

It provides easy instructions for installing old versions of packages, it takes them straight from the official nixpkgs repo.

Example: https://history.nix-packages.com/package/dotnet-sdk_3/3.1.426 (.NET SDK 3.1 actually prompted the creation of this tool, I needed it for one old project).

Each detail page provides instructions on how to install the package using nix-shell, nix-shell with shell.nix file, configuration.nix and nix-env.

The design is based on https://search.nixos.org (because I suck at graphical design).

Do let me know what you think!

40
 
 

I made a post a while ago asking what you do when NixOS isn't cutting it. You need a package that isn't available as a flatpak/appimage or already in nixpkgs. You don't want to build from source, because it's either too difficult or too time consuming. One suggestion was containerization or virtual machines, but those seemed too cumbersome. Well, distrobox is the tool that fixes it.

Distrobox is a shell script that wraps over docker/podman to run a container of a distribution of your choice. But it does it behind a very high level API, and integrates the container environment seemlessly with your host environment. It is seriously as easy as this, if you need to install something with apt inside debian.

$ distrobox create -n my_debian --image debian:latest
$ distrobox enter my_debian

And bang, your in a debian container and it won't even feel like it. It automatically integrates your shell environment and maps your root directory inside the container (or something like that.) You seriously wouldn't know unless you neofetch. Best part is that since everything is in the nix store, every program in your environment should work, for the most part, inside this container. I've not noticed problems yet.

Tada! apt is available in this environment and you can install what you need. Then you can run it while inside the container. From the host machine, outside the container, you can run it directly too. Say you installed program X in debian:

$ distrobox enter my_debian -- X

And it will just run the command and send you back to the host machine.

In the case of docker, you can type docker ps and it will show you your debian image my_debian listed.

There's two more things I want to do to really polish this workflow. The first is to change my shell prompt so I know that I'm actually in debian without typing neofetch! Inside the box the variable CONTAINER_ID is set and the hostname is modified. I've adjusted my starship prompt to look like this when inside the box:

distrobox:my_debian ~ $

And lastly, I really want to blur the lines. If I install X in debian, I want to just call it directly from the host as X, not invoke my debian instance with distrobox enter.

When you type X and the program is missing, bash (and fish and zsh I'm sure) runs a hook that you can look at by typing

$ declare -p -f command_not_found_handle

By overriding this, you could first have it try the inside container if it can't find the application in the host container, like so.

command_not_found_handle () {
  distrobox enter my_debian -- $@
}

This is not a perfect solution, but I'm still experimenting with how to integrate this both seamlessly and also not accidentally run things inside debian and not realize it. If you have suggestions for how to improve handling calling commands from the outside environment, please share. Best case might just be adding aliases for programs explicitly. For example, `alias X=distrobox enter my_debian -- X.

Anyway, distrobox is the solution! This is one more barrier removed that was preventing me from moving my main computer over to NixOS. I'm so happy to have found this and wanted to share.

41
 
 

I was trying to use a flake with nix-pkg to set up a flutter dev environment but it just wouldn't stick, and a lot of the examples online are quite old and not documented well for a nix noob like myself.

Cheers folks!

42
 
 

I've been hearing a lot about it lately and I'm intrigued, but also utterly confused.

Is this a Linux distro I'd install on bare metal because it offers a new way of package management that addresses the issues other distros have?
Is it something I install in the distro I currently use?
How does it work and what does it do?

I've tried to read https://nixos.org/guides/how-nix-works but the first sentence is

"Nix is a purely functional package manager. This means that it treats packages like values in purely functional programming languages such as Haskell"

and that's where it lost me. Thanks for helping me understand!

43
44
45
 
 

My server is currently running fedora and it has a encrypted raid attatched. Now i wanna move my server to nixos but i cant find anything on how to automount it. Any advice ? Thanks for your time and have a nice day!

46
 
 

I've been spending a couple weeks unable to modify my system, because using my window manager was ungodly slow (like 1fps.) Luckily NixOS lets you pick a previous generation to load so I could make changes, build a new generation, and try again.

It took me too long to find, but I realized I had both the x session managed by both nixos and home manager. Removing this fixed the problem. I assume this had 2 xsessions open and they were competing for resources or something. Be cautious! :)

47
 
 

Every now and then I see a program that doesn't have a default.nix or flake.nix in the source, doesn't have an entry in nixpkgs, and otherwise can't find a derivation for. So I write them myself.

What's the best way to share these? Should I contribute to nixpkgs? (does this count if I'm making flakes?) Do I maintain a single repo for each program? Or do I create a repo with a collection of flakes? Something else?

48
 
 

Used nix last year but dropped it after home-manager decided to unlink the apps from the Applications directory.

How is the current situation on usability of nix-Darwin + home-manager + brew?

Packages still fails to get indexed correctly in spotlight? I really like a fully repro environment but the fact that the usu ability was low bothered me a lot.

49
 
 

I recently wanted to try out (aider)[https://aider.chat], and ran into a problem that I continually run into: how do I install one-off, experimental software into my environment, without being a nix master, or spending an extreme amount of time on every new package.

In this case, it is a new python package available in pip. It isn't available in nixpkgs, and isn't nixified. pip2nix doesn't work on arm64 Macs (bug here)[https://github.com/nix-community/pip2nix/issues/88], so I can't use that to try and create a flake that works with this package. It isn't using poetry, so poetry2nix is out.

How are you dealing with this problem? Are you all experts in nix, and writing flakes for every piece of software that you want to play around with? Do you have a "dirty" part of your environment that you install this kind of stuff into? (I looked into using pipx to install this, however that (also has a bug)[https://github.com/NixOS/nixpkgs/issues/171429] in nixpkgs.)

Thoughts?

50
3
submitted 1 year ago* (last edited 1 year ago) by rikudou@lemmings.world to c/nixos@infosec.pub
 
 

Hi there! I'm trying to make php and composer work. I have this in environment.systemPackages:

    (pkgs.php82.buildEnv {
      extensions = ({ enabled, all }: enabled ++ (with all; [
        xdebug
        redis
      ]));
      extraConfig = ''
        memory_limit=2G
        xdebug.mode=debug
      '';
    })
    php82Extensions.redis

The problem is that while running php -m correctly prints that redis extension is installed, composer does not, because it uses a different php:

  • file $(which php) prints the path /nix/store/igx8j4qjxy9jyj8kjyccwarnzqq5vsml-php-with-extensions-8.2.9/bin/php
  • cat $(which composer) shows that it's a wrapper for '/nix/store/lv4prxa52zifr54ws56iz3b9kdhs1b5w-php-with-extensions-8.2.9/bin/php' --add-flags '/nix/store/avqj0662f4gg2s875zlbbjajx6fm6bl0-php-composer-2.5.5/libexec/composer/composer.phar'

Note that the path to php is different. Is there any way to correct it on my side? I'd like to avoid having to install composer manually

view more: ‹ prev next ›