Skip to content

DynamicGoose/dot-files

Repository files navigation

dot-files

My multi-host NixOS flake!

Usage

Setting up a new host

Important

If you want to adapt these dot files for yourself be sure to configure your own hosts.

  1. Add a new entry to nixosConfigurations in flake.nix:
# ...
nixosConfigurations = lib.genHosts = {
  new-host = {
    username = "new-host-user";
    userDescription = "probably your name (for display-manager)";
    # Other options you may want to change:
    # arch (default: "x86_64-linux")
    # hostname (default: config name)
  };
  # ...
};
# ...
  1. Create default.nix in hosts/new-host/. Import modules like hardware-configuration.nix or config.nix from there.
  2. Have a look at options.md for my custom configuration options.

Building the System

  1. After setting up your hosts run copy_config.sh:
./copy_config.sh
  1. For the first rebuild with this config rebuild like this:
sudo nixos-rebuild boot --install-bootloader --flake /etc/nixos#<config-you-want-to-build>

Afterwards, you can run sudo nixos-rebuild switch|boot|etc. like normal.

nh

After the first build you can also use nh:

  1. Set modules.programs.nh.configPath to your /path/to/nixos-config before your first rebuild. (default is /home/${username}/git/dot-files)
  2. Rebuild the system with nh os switch|boot|etc.

Development Shells

In the shells directory, there are also a couple of nix shells for different usecases. You can enter the default dev shell with nix develop.
Other shells can be invoked as you would expect. E.g.:

nix develop .#nix

Warning

These shells cannot be used through nix-shell. This was a conscious decision because I wanted them to always be as reproducable as the rest of the system.

Library Functions

This flake also provides library function similar to lib in nixpkgs. These can be used in other flakes.

Currently, these functions are provided:

  • lib.mkHost: for more easily defining new hosts using this flake
  • lib.genHosts: used in flake.nix and maps attribute sets onto lib.mkHost
  • lib.eachSystem: defining stuff for all architectures

Usage Example

This is taken from the flake.nix from another of my projects.

{
  description = "Magma-ECS dev shell";

  inputs = {
    dot-files.url = "git+https://codeberg.org/DynamicGoose/dot-files.git";
  };

  outputs =
    { self, dot-files }:
    {
      devShells = dot-files.lib.eachSystem (pkgs: {
        default =
          let
            libPath =
              with pkgs;
              lib.makeLibraryPath [
                vulkan-loader
              ];
          in
          pkgs.mkShell {
            name = "magma-ecs";
            nativeBuildInputs = with pkgs; [
              rustc
              cargo
              gcc
              rust-analyzer
              rustfmt
              clippy
            ];

            buildInputs = with pkgs; [
              pkg-config
            ];

            LD_LIBRARY_PATH = "${libPath}";
            RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
          };
      });
    };
}

About

My NixOS Config (Mirror)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published