nixos

1262 readers
8 users here now

All about NixOS - https://nixos.org/

founded 4 years ago
26
 
 

I've seen people use nix-doom-emacs, have it set up standalone, and some have fancy Nix code that's way beyond my understanding for now to set it up. Which one is the recommended way to set it up? Also, how do you get completions in nix-mode?

27
 
 

I've been using Nix and NixOS for 4 years now. While I like using it for my PCs and tried using it for servers with success, I think its ecosystem still is immature for development and production purposes, and thus my passion for Nix has faded.

So my question is what keeps you using Nix or NixOS? How have you been using it? Do you still feel passion and hype for it?

28
 
 

Yesterday I tried to update my nix flake but the rebuild-switch failed when it came time to install the following python3 derivation with some extra python packages:

(python3.withPackages(ps: with ps; [ numpy scipy matplotlib pandas notebook ]))

The problematic package is "notebook" and building fails with the following error:

error: builder for '/nix/store/crxnqidkwkgxm9s7ahkhvilx1cisrki6-python3.10-jupyter-server-2.0.6.drv' failed with exit code 1;
       last 10 log lines:
       >     pyfuncitem.obj(**testargs)
       >   File "/build/jupyter_server-2.0.6/tests/extension/test_launch.py", line 105, in test_base_url
       >     launch_instance(["--ServerApp.base_url=/foo"])
       >   File "/build/jupyter_server-2.0.6/tests/extension/test_launch.py", line 83, in _run_in_subprocess
       >     wait_up(url, check=lambda: process.poll() is None)
       >   File "/build/jupyter_server-2.0.6/tests/extension/test_launch.py", line 40, in wait_up
       >     time.sleep(interval)
       >
       >  Timeout
       > /nix/store/gv2cl6qvvslz5h15vqd89f1rpvrdg5yc-stdenv-linux/setup: line 1604: pop_var_context: head of shell_variables not a function context

The very same python derivation worked like 2 weeks ago but now suddenly doesn't work anymore. I'm quite lost trying to troubleshoot this problem so any help is greatly appreciated.

EDIT: So far I've tried the "jupyter" package instead of the "notebook" package, installed it through the unstable channel and tried to install "jupyterlab" as an alternative, but to no avail.

29
 
 

after updating to the new version of Dolphin, I noticed the icons don't show up in the "Icons" layout.

30
31
32
 
 

If anyone wants to help package COSMIC in nixpkgs (and for NixOS) join the Matrix room :3

33
 
 

I hope this is the right place to ask. I am new to Nix and trying to use it for now as a universal package manager. I installled Stremio using Nix but the app doesn't work properly. I see that it's several versions out of date. The same app works fine using Flatpak. Is there a way to let the maintainer know? I'd also love some documentation that can help me update it myself. I can just use the Flatpak but I just want to have one less package manager to worry about.

34
 
 

I'm developing a small library which intercepts some library calls from a program installed via home-manager. My library works fine outside of nix, but it fails when trying to intercept calls from a program installed via home-manager. I figured that it is related to hardcoded library paths in my interceptor library.

lld shows

linux-vdso.so.1 (0x00007fff7a341000)
libasound.so.2 => /lib/x86_64-linux-gnu/libasound.so.2 (0x00007fb2f3b72000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb2f391c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb2f38f8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb2f3716000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb2f3637000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb2f3cac000)

What is the preferred approach here?

  • Changing the paths in my binary doesnt seem very portable?
  • Setting LD_LIBRARY_PATH seems also a hassle
  • Are there linker settings which could help
  • Or, should I "just" (no idea, how to do this) create a derivation for my program and install it via home-manager, too?

Any pointers are greatly appreciated. Cheers!

35
 
 

Could be areas of improvement as well

36
15
Tried NixOS ! (dvd.chat)
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

Tried NixOS !

So I tried nixos and I love how things work, I am glad that it exists. Will learn about Flakes today. Any recommended resource to learn it? :)

@[email protected]

37
 
 

I want to call the escapeSystemdPath (defined in nixpgs at nixos/lib/utils.nix) to derive the name of a systemd mount unit from the target path (eg. srv-my-dir.mount from /srv/my/dir), but I can't figure out how I can reference it... any ideas?

38
3
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

I want to add custom commands to my PATH but am unable to get it working. So far I've installed home-manager and added the code below to my nix configuration.

imports = [
  ./hardware-configuration.nix
  
];

Then later on to add the item to PATH

home-manager.users.curtismchale = { pkgs, ... }: {
  home.stateVersion = "23.05";
  home.sessionPath = [
    "$HOME/Workspace/proudcity/proudcity-kubernetes/bin"
  ];
};

I have also tried $HOME/Workspace/proudcity/producity-kubernetes/bin/pc-kube but that doesn't change the issue.

I can see the commands installed at ~/Workspace/proudcity/proudcity-kubernetes/bin/pc-kube but when I type the expected command pc kube $command it says there is nothing installed in path and offers to install some programs that match pc for me.

39
5
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

I'm playing around with nixos in a few VMs and at some point I realized I must have lost the swap configuration in one of my refactorings.

To my surprise, however, the VMs do use the swap partitions I had set up.

There is no mention on "swap" in my nix configuration (or in fstab) and no .swap units in /etc/systemd/system; I do however have a swap partition labelled "swap".

Turns out there is a systemd unit (albeit not a corresponding file) that sets up swap:

[root@vm1:~]# free -hw
               total        used        free      shared     buffers       cache   available
Mem:           2.8Gi       664Mi       955Mi       4.0Mi       3.0Mi       1.3Gi       2.0Gi
Swap:          3.7Gi          0B       3.7Gi

[root@vm1:~]# systemctl list-dependencies swap.target 
swap.target
● └─dev-disk-by\x2ddiskseq-1\x2dpart3.swap

I'm wondering where the unit comes from? Can I rely on this and never configure swap ever again?

40
 
 

I have an option that must be left with the default value when a certain flag (another option) is false.

I didn't find any example (let alone documentation) on how to implement this, so I've come up with two ideas:

option-that-errors-out-if-set-when-flag-is-false =
let
  default = if config.some-flag
          then "some default value for when flag is true"
          else "value that should not be changed when flag is false";
in lib.mkOption {
  type = lib.types.str;
  inherit default;
  apply = v: assert assertMsg (config.some-flag || v == default) "Do not set this option unless 'flag' is true";
          v;
};
option-that-ignores-value-when-flag-is-false =
let
  default = if config.some-flag
          then "some default value for when flag is true"
          else "value that should not be changed when flag is false";
in lib.mkOption {
  type = lib.types.str;
  inherit default;
  apply = v: if config.some-flag then v else default;
};

Which one do you think is "best" (cleaner, more idiomatic, etc..)?

Is apply the "right" place to validate options? Should I make a custom type instead? Should I approach this in some different way?

41
 
 

I'd like to set a "global" option from within a submodule, but the config I return is grafted into the "global" under the submodule "path" rather than at the root... any idea if it's somehow possible?

Er... I guess I didn't make a great job at explaining what I want to do... Some code will hopefully help.

In mymodule.nix I have:

{ lib, config, ... }: {

  options.myoption = lib.mkOption {
      type = lib.types.attrsOf (lib.types.submodule (
        import ./mysubmodule.nix
      ));
  };

}

and mysubmodule.nix is:

{ name, lib, config, ... }: {

options.mysubmoduleoption = {
  type = lib.types.str;
};

config = {
  # here I want to set a "global" option, say "systemd.mounts"
  # based on the value of "mymodule.name.mysubmoduleoption"
  # but it seems I can only set values under "mymodule.name" 
};

}
42
8
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

I'm trying to debug a module I'm writing with builtins.trace, but it's being more complicated than I anticipated.

Let's say I have a module:

{ config, lib, pkgs, modulesPath, ... }:

{

  config =
  let
    some-list = lib.attrsets.mapAttrsToList (n: v: {
        some-attr = "${n} ${v}";
    }) { n1 = "v1"; n2 = "v2"; };
  in {
    users.mutableUsers = builtins.trace (some-list) false;
  };

}

This will print

trace: [ <code> <code> ]

because builtins.trace (for whatever reason?) evaluates its first argument only shallowly.

Changing the trace expression to:

builtins.trace (builtins.toJSON some-list) false;

helps a lot, but as soon as one tries to print a long list or a structure with some complexity the output is completely unreadable, and it's not like it can easily be piped into jq (I mean... &amp;| grep ^trace: | sed 's/trace: //' | jq works*, but there must be a "better" way?)

(*) in fish shell, IDK about bash

edit: It's not like I specifically want JSON output: any format will do (ideally, nix would be nice)

43
2
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

Edit: Solved at https://lemmings.world/comment/1719409


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

44
 
 

I need to generate a number of scripts in my configuration and make them into a single package (for ease of reference, because there are a lot of them).

So far, I'm creating the scripts via writeShellApplication, making them into packages via an overlay, merging them with buildEnv and then adding the resulting package to `systemPackages.

Something like:

nixpkgs.overlays = [ (final: prev: {
  my-hello-1 = final.writeShellApplication {
    name = "my-hello-1-script";
    text = "echo my hello wolrd 1";
  };
  my-hello-2 = final.writeShellApplication {
    name = "my-hello-2-script";
    text = "echo my hello wolrd 1";
  };
  my-hello-scripts = final.buildEnv {
    name = "my-hello-scripts";
    paths = [ final.my-hello-1 final.my-hello-2 ];
  };
}) ];

environment.systemPackages = [ pkgs.my-hello-scripts ];

This works, but I don't really need the my-hello-1 and my-hello-2 packages... can you think of a way to make do without needing them?

45
 
 

I'm migrating my NAS to nixos, and I got to the point of setting up my restic backups.

services.restic.backups is great, but -- on top of the systemd timers/services -- I also want some helper scripts (eg. one to easily mount the backups, stuff that with ansible I currently generate into /usr/local/sbin).

These scripts would be entirely generated from the services.restic.backups config and would reference sops secrets also from configuration.nix, so... I don't think it would make sense to make a package out of them?

What should I use to make these scripts? Should I use nixpkgs.writeShellApplication and then alter the PATH?

46
 
 

I was configuring DWM, among other things, for the last 3-4 days, and every single rebuild switch caused a new generation to appear. There were too many Systemd-boot entries so they couldn't even fit on the screen and continued down to Gen 41. It's just crazy.

Edit: This post: https://feddit.uk/post/1454174 shows the rest of the boot entries

47
 
 

Im just starting out in my nixos journey. This thought came to me in the shower: would nixOS lend itself for a phone OS?

48
 
 

I couldn't find a nix community, so I'm hoping it is ok that I'm posting on the nixos one instead. I'll switch to mailing list/discord if necessary, but I have a lemmy app on my phone, and it is much easier to have an ongoing conversation from here, so I decided to give it a shot. Here goes!

While I have a NixOS laptop, I primarily use other systems (e.g. OpenSuse Tumbleweed) as of now.

I love the ability to define the packages I want installed, with home-manager managing my command line utilities (e.g mtr, dig, protobuf etc).

I've been playing around a bit with protobuf recently, and after generating some c++ code using protoc, I loaded up the generated code in vscode, which understandably wasn't able to find the development headers for protobuf (since they are in the nix store - /nix/store/h2h5fs8iv2a8rmlkfhr6id6y4jxwd5i1-protobuf-3.21.12/include/google/protobuf/io)

I tried to compile the code anyways on the command line, and got some errors.

I might need an OS specific protobuf install just for the development headers, but I'm pretty sure I should be able to, and just don't know how. Here's what I get when I try to compile:

$ g++ searchReq.pb.cc
In file included from searchReq.pb.cc:4:
searchReq.pb.h:10:10: fatal error: google/protobuf/port_def.inc: No such file or directory
   10 | #include 
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

Any tips/pointers would be appreciated. Thanks in advance!

===========================================

Edit: Thank you all, particularly @[email protected] and @[email protected] for the help. After setting the include path (compile) and LD_LIBRARY_PATH (link), things work great.

I ended up writing a small Makefile for convenience in the short run:

INC_FLAGS:=-I$(HOME)/.nix-profile/include -Icpp
LD_FLAGS:=-L$(HOME)/.nix-profile/lib -l protobuf

run: task
	LD_LIBRARY_PATH=$(HOME)/.nix-profile/lib ./task

task:
	g++ $(LD_FLAGS) $(INC_FLAGS) main.cpp cpp/searchReq.pb.cc -o task

regen:
	protoc --python_out=python --cpp_out=cpp searchReq.proto

That's enough to get me going for now.

TODO - read up the NIXOs Wiki C page in more detail

49
50
 
 

I have a personal source project I created a shell.nix file for. However, in the project I have also scripts I want to execute periodically non-interactively. Could I use the nix-shell shebang pointing to shell.nix file in order to have the same programs when I use nix-shell interactively and when I launch the scripts?

view more: ‹ prev next ›