!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

881 Members
175 Servers

Load older messages


SenderMessageTime
7 Mar 2024
@samasaur:matrix.orgsamasaur for 1, let's say you have two nixos machines, hostA and hostB. then you could have a common.nix file that contains config that they both have, and then have a hostA.nix and a hostB.nix file that contain config unique to machines A and B respectively. then flake.nix could define the system configurations and import the corresponding files as modules 09:10:18
@samasaur:matrix.orgsamasaur for 2, keeping flake.nix and configuration.nix as separate files means that (usually) when changing the machine config, you only make changes to configuration.nix, and (usually) when restructuring config/adding new machines or other outputs, you only make changes to flake.nix. this means that when you look back in version control, both types of changes are not combined in the history of a single file 09:12:34
@samasaur:matrix.orgsamasaur but neither of these are requirements — if you would prefer to have everything in one file, you can do so 09:12:55
@dyerat:matrix.orgdyerat for the nix.settings.experiemental-features = [ "nix-command" "flakes" ] line, would that always be required in the configuration.nix file / always requiring me to home one called exactly that 09:14:45
8 Mar 2024
@gsaurel:laas.frnim65sHello ! I have project A which has nixpkgs + flake-utils as inputs. fine. Then project B which depend on A, so nixpkgs + flake-utils + A (whose nixpkgs & flake-utils inputs follows B inputs). Then for project C which depends on B… I am supposed to write nixpkgs + flake-utils + A (whose nixpkgs + flake-utils inputs follows C inputs) + B (whose nixpkgs + flake-utils + A inputs follows C inputs), right ? It's going to be a lot of boilerplate fast, isn't it ?13:57:14
@gsaurel:laas.frnim65sMaybe I should contribute A & B to nixpkgs, so that C only depends on nixpkgs 😅14:05:25
@gsaurel:laas.frnim65s * Maybe I should contribute A & B to nixpkgs, so that C only depends on nixpkgs + flake-utils 😅14:05:37
@mtxyz:the-apothecary.club@mtxyz:the-apothecary.club joined the room.14:06:47
@kyle:iteratee.net@kyle:iteratee.net joined the room.20:00:30
9 Mar 2024
@qyriad:matrix.org@qyriad:matrix.org left the room.00:36:30
@tengkuizdihar:matrix.orgtengkuizdihar
In reply to @gsaurel:laas.fr
Hello !
I have project A which has nixpkgs + flake-utils as inputs. fine. Then project B which depend on A, so nixpkgs + flake-utils + A (whose nixpkgs & flake-utils inputs follows B inputs).
Then for project C which depends on B… I am supposed to write nixpkgs + flake-utils + A (whose nixpkgs + flake-utils inputs follows C inputs) + B (whose nixpkgs + flake-utils + A inputs follows C inputs), right ? It's going to be a lot of boilerplate fast, isn't it ?
Wonder what the boilerplate looks like, but if this is a serious question, maybe you could post this on the forum. Its more discoverable that way
02:51:03
@amiablechief:matrix.org@amiablechief:matrix.org joined the room.03:14:34
@jee_mj:matrix.orgmj joined the room.03:36:12
@gsaurel:laas.frnim65sthanks :)08:22:42
@fractivore:cyberia.club@fractivore:cyberia.club
In reply to @dyerat:matrix.org
for the nix.settings.experiemental-features = [ "nix-command" "flakes" ] line, would that always be required in the configuration.nix file / always requiring me to home one called exactly that
I don't really understand the second part of your question, "always requiring me to home one called exactly that", would you mind clarifying a bit?
But the answer to your first question is yes, you always need that line as far as I know.
20:17:19
10 Mar 2024
@maribox:matrix.orgmariboxRedacted or Malformed Event02:54:58
@maribox:matrix.orgmaribox *

Hey! I am currently on the jouney of learning nix and modularizing my config. I tried adding a basePath to my flake.nix because I thought it's a good idea to make the paths absolute but now when I try to rebuild I get the error

"error: cannot coerce a set to a string"

and I have no clue what that even means and also didn't find a clear explanation on the internet.

It would be amazing if someone could help me.

my code for flake.nix looks like this:

{
 description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    alejandra.url = "github:kamadorueda/alejandra/3.0.0";
    alejandra.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs @ {
    nixpkgs,
    home-manager,
    alejandra,
    ...
  }: 
let 
        homeDir = builtins.getEnv "HOME";
        basePath = homeDir + "/nixos-config";
in 
{
     nixosConfigurations = {
      tunix = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          builtins.toPath "${basePath}/hosts/lat"
          builtins.toPath "${basePath}/configuration.nix"
          {
            _module.args = {inherit alejandra;};
          }
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.marri = import builtins.toPath "${basePath}/home.nix";

            # Optionally, use home-manager.extraSpecialArgs to pass
            # arguments to home.nix
          }
        ];
      };
    };
  };
}
02:55:12
@maribox:matrix.orgmaribox *

Hey! I am currently on the jouney of learning nix and modularizing my config. I tried adding a basePath to my flake.nix because I thought it's a good idea to make the paths absolute but now when I try to rebuild I get the error

"error: cannot coerce a set to a string"

and I have no clue what that even means and also didn't find a clear explanation on the internet.

It would be amazing if someone could help me.

my code for flake.nix looks like this:

{
 description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    alejandra.url = "github:kamadorueda/alejandra/3.0.0";
    alejandra.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs @ {
    nixpkgs,
    home-manager,
    alejandra,
    ...
  }: 
let 
        homeDir = builtins.getEnv "HOME";
        basePath = homeDir + "/nixos-config";
in 
{
     nixosConfigurations = {
      tunix = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          builtins.toPath "${basePath}/hosts/lat"
          builtins.toPath "${basePath}/configuration.nix"
          {
            _module.args = {inherit alejandra;};
          }
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.marri = import builtins.toPath "${basePath}/home.nix";

            # Optionally, use home-manager.extraSpecialArgs to pass
            # arguments to home.nix
          }
        ];
      };
    };
  };
}

The reason the let in is not at the start but at the outputs section is this issue:
https://github.com/NixOS/nix/issues/3966

02:56:01
@maribox:matrix.orgmariboxRedacted or Malformed Event02:57:16
@stablejoy:matrix.org@stablejoy:matrix.org joined the room.04:08:11
@sdvohet:matrix.orgSdvohet joined the room.08:11:31
@accelbread:matrix.org@accelbread:matrix.orgIs the flake.lock file format documented anywhere?21:12:15
11 Mar 2024
@sky1e:mildlyfunctional.gay@sky1e:mildlyfunctional.gay joined the room.00:34:57
@maribox:matrix.orgmaribox *

Hey! I am currently on the jouney of learning nix and modularizing my config. I tried adding a basePath to my flake.nix because I thought it's a good idea to make the paths absolute but now when I try to rebuild I get the error

"error: cannot coerce a set to a string"

and I have no clue what that even means and also didn't find a clear explanation on the internet.

It would be amazing if someone could help me.

my code for flake.nix looks like this:

{
 description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    alejandra.url = "github:kamadorueda/alejandra/3.0.0";
    alejandra.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs @ {
    nixpkgs,
    home-manager,
    alejandra,
    ...
  }: 
let 
        homeDir = builtins.getEnv "HOME";
        basePath = homeDir + "/nixos-config";
in 
{
     nixosConfigurations = {
      tunix = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          builtins.toPath "${basePath}/hosts/lat"
          builtins.toPath "${basePath}/configuration.nix"
          {
            _module.args = {inherit alejandra;};
          }
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.marri = import builtins.toPath "${basePath}/home.nix";

            # Optionally, use home-manager.extraSpecialArgs to pass
            # arguments to home.nix
          }
        ];
      };
    };
  };
}

The reason the let in is not at the start but at the outputs section is this issue:
https://github.com/NixOS/nix/issues/3966

02:16:11
12 Mar 2024
@phileas:asra.gr@phileas:asra.gr joined the room.22:24:59
@phileas:asra.gr@phileas:asra.gr
In reply to @accelbread:matrix.org
Is the flake.lock file format documented anywhere?

https://github.com/NixOS/nix/blob/bff5c94184e0eee2a093f3e04d4cec5010de81c7/src/nix/flake.md#lock-files

This goes technical in-detail, overall searching for flake.lock inside nix.git might also help understanding it on a lower-level: https://github.com/search?q=repo%3ANixOS%2Fnix%20flake.lock&type=code

22:30:31
@accelbread:matrix.org@accelbread:matrix.org
In reply to @phileas:asra.gr

https://github.com/NixOS/nix/blob/bff5c94184e0eee2a093f3e04d4cec5010de81c7/src/nix/flake.md#lock-files

This goes technical in-detail, overall searching for flake.lock inside nix.git might also help understanding it on a lower-level: https://github.com/search?q=repo%3ANixOS%2Fnix%20flake.lock&type=code

thanks!
23:11:24
@tomberek:matrix.orgtomberek accelbread: note that we are considering a lock format change in the future, prior to flake stabilization 23:14:23
@accelbread:matrix.org@accelbread:matrix.org Makes sense; i needed to parse current lockfiles to get inputs.
Can just update logic to add support for new version when that arrives
23:16:40
13 Mar 2024
@alexeusgr:matrix.org50^2 changed their profile picture.13:46:58

Show newer messages


Back to Room ListRoom Version: 6