Code Monkey home page Code Monkey logo

Comments (10)

luxus avatar luxus commented on June 16, 2024

i tried to do it myself but i still struggle with the syntax and the understanding for nix :(

https://github.com/luxus/nix-config/blob/mychanges/lib/default.nix

from nix-config.

Misterio77 avatar Misterio77 commented on June 16, 2024

Hey,

The issue with your file is that you have one function input and one output. It should be:

{
  mkNixos = {
    hostname,
    system,
    persistence ? false,
  }:
    nixosSystem {
      inherit system;
      pkgs = outputs.legacyPackages.${system};
      specialArgs = {
        inherit inputs outputs hostname persistence;
      };
      modules =
        attrValues (import ../modules/nixos)
        ++ [
          ../hosts/nixos/${hostname}
        ];
    };

  mkDarwin = {
    hostname,
    system,
    persistence ? false,
  }:
    darwinSystem {
      inherit system;
      pkgs = outputs.legacyPackages.${system};
      specialArgs = {
        inherit inputs outputs hostname persistence;
      };
      modules =
        attrValues (import ../modules/darwin)
        ++ [
          ../hosts/darwin/${hostname}
        ];
    };
}

from nix-config.

Misterio77 avatar Misterio77 commented on June 16, 2024

Oh and by the way, you might be better served trying out my nix-starter-configs. They are really complete, yet easy to understand for people starting out with nix (package manager and/or language).

My config is a tad complex (you probably don't need to make a function for defining systems, for example) and overall "here be dragons".

from nix-config.

luxus avatar luxus commented on June 16, 2024

okay.. i think it was too late yesterday :D

i still struggle to get it working. i will take a further look tomorrow. maybe i will figure it out

i'm pretty far with your config i got it working on 2 computers and from now on it looks a lot easier.
impersistence is a pain in the ass but i got it mostly.
https://mt-caret.github.io/blog/posts/2020-06-29-optin-state.html
i will try to use the diff script there to see what i'm still missing (my volume resets)

from nix-config.

luxus avatar luxus commented on June 16, 2024

@Misterio77 if you have the time to take a look on my fork of your config https://github.com/luxus/nix-config/blob/mychanges/lib/default.nix i would really appreciate it :D

from nix-config.

Misterio77 avatar Misterio77 commented on June 16, 2024

Looks good :)

But I'd advise you to instead start with a smaller config and work your way up. Nix code can be cryptic, so it's best if you start with code that you fully understand (of course, that isn't possible at the very beggining, so start with the simplest code possible), and build your own complexity as you progress. Dealing with complex abstractions you don't need will make it a LOT harder to learn.

from nix-config.

Misterio77 avatar Misterio77 commented on June 16, 2024

If you're interested in the abstractions, go right ahead. But if the thing you need is impermanence, I can help you write a minimum viable flake.

from nix-config.

luxus avatar luxus commented on June 16, 2024

thanks for the advice, your config is not the first i tried :D and you are right it's easier with a smaller config. but i want to use the config on at least 5 machines, so your abstactions are really helpful.

as i posted in a other issue. your config is so far the most easiest to understand "complex config". i got nearly everything working and understand most of it so far. but the abstraction is a little bit much. :D
i moved the nixOS configs to /hosts/nixOS/
but couldn't access common ../../common didn't work? is it not possible to go 2 folders up?
when i try to use the config on a mac i got following error:

❯ darwin-rebuild switch --flake .
warning: Git tree '/Users/luxus/Source/nix-config' is dirty
building the system configuration...
warning: Git tree '/Users/luxus/Source/nix-config' is dirty
error: attribute 'darwinSystem' missing

       at /nix/store/vmfbw1rwrfq3sm4dmlisx76lwjd65210-source/lib/default.nix:1:19:

            1| {inputs, ...}: let
             |                   ^
            2|   inherit (inputs) self home-manager nixpkgs deploy-rs ;

do i have to separate the mkHome between darwin and nixOS aswell?

from nix-config.

Misterio77 avatar Misterio77 commented on June 16, 2024

your config is so far the most easiest to understand "complex config". i got nearly everything working and understand most of it so far. but the abstraction is a little bit much. :D

that makes sense.

but couldn't access common ../../common

Hm, it should work. In which file is this error happening?

error: attribute 'darwinSystem' missing

In lib/default.nix line 6, you're trying to import darwinSystem from nixpkgs.lib. You should import it from darwin.lib instead. Like so:

{inputs, ...}: let
  inherit (inputs) self home-manager nixpkgs deploy-rs darwin;
  inherit (self) outputs;

  inherit (builtins) elemAt match any mapAttrs attrValues attrNames listToAttrs;
  inherit (nixpkgs.lib) nixosSystem filterAttrs genAttrs mapAttrs';
  inherit (darwin.lib) darwinSystem;
  inherit (home-manager.lib) homeManagerConfiguration;

  activate = type: config: deploy-rs.lib.${config.pkgs.system}.activate.${type} config;
in rec {
# ...
}

from nix-config.

luxus avatar luxus commented on June 16, 2024

thanks that worked..
i could be more clever and just add a if statement with stdenv.hostplatform.isDarwin

from nix-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.