As the title says. Want that i can have a single config for my systems and just require a single line to install and configure software which i always use in a bundle(office, specific programming applications, server applications,…).

  • Corbin@programming.dev
    link
    fedilink
    English
    arrow-up
    7
    arrow-down
    1
    ·
    1 day ago

    I’m a fan of putting factored expressions into their own files and importing those files as NixOS modules. For example, let’s say that we want to install vim. We might start with a vim.nix:

    { pkgs, ... }: {
      environment.systemPackages = [ pkgs.vim ];
    }
    

    Then in the main configuration, this can be imported by path:

    {
        imports = [ ./vim.nix ];
    }
    

    Adding the import is like enabling the feature, but without any options or config. Later on, the feature can be customized without changing the import-oriented usage pattern:

    { pkgs, ... }:
    let
      vim = ...;
    in {
      environment.systemPackages = [ vim ];
    }
    

    Since the imported file is a complete NixOS module, it can carry other configuration. Here’s a real example, adb.nix, which adds Android debugger support:

    { pkgs, ... }: {
      programs.adb.enable = true;
      environment.systemPackages = [ pkgs.pmount ];
      users.users.corbin.extraGroups = [ "adbusers" ];
    }