nixos-config/docs/content/en-US/using-parts-of-my-configuration/index.adoc

4.6 KiB
Raw Blame History


title: Using parts of my configuration --- = Using parts of my configuration

Hey there, stranger. Wanted to try parts of my configuration but dont want to copy it outright since youre feeling lazy or what-have-you? I made my configuration to be easy to use and integrate into your system.

Heres how…

With flakes

This is the recommended method since I primarily use flakes for this project. Not to mention that with flakes, this is easier than ever to make use parts of my configuration.

To start, you can simply add my flake to your list of flake inputs.

inputs.foo-dogsquared-nixos-config.url = "{canonical-flake-url}";

Then, you could use parts of the config as exported from my flake which you can refer back to Whats in my flake?.

For example, you could make use of my packages by adding them as an overlay which is recommended if youre going to use my NixOS modules anyways. Heres one way to put as part of your NixOS configuration…

{
  nixpkgs.overlays = [
    inputs.foo-dogsquared-nixos-config.overlays.default
  ];
}

or import them as part of nixpkgs.

import nixpkgs {
  system = "x86_64-linux";
  overlays = [
    inputs.foo-dogsquared-nixos-config.overlays.default
  ];
}

If youre going to use my stuff, why dont take a gander and try my non-personal parts of the configuration such as my github:{github-repo}[NixOS modules, path=./modules/nixos/, rev=master] and github:{github-repo}[home-manager modules, path=./modules/home-manager/, rev=master]? In that case, you can simply plop them into your list of imports for your NixOS configuration like so.

{
  imports = [
    inputs.foo-dogsquared-nixos-config.nixosModules.programs
    inputs.foo-dogsquared-nixos-config.nixosModules.services
    inputs.foo-dogsquared-nixos-config.nixosModules.workflows
  ];

  # Use my GNOME desktop configuration for some reason.
  workflows.workflows.a-happy-gnome.enable = true;
}

With channels

The traditional way of managing stuff with channels. Though, I have made some efforts to make it easy to use without flakes, I cannot guarantee its good compared to using it with flakes.

Warning
You cannot install my NixOS configurations at all with channels so theres another reason why (whether is valid or not is completely up to you).

To start, as root, you have to add my project into the channels list…

nix-channel --add "{canonical-flake-url-tarball-master}" foo-dogsquared-nixos-config
nix-channel --update

then import my config as part of your configuration.

import <foo-dogsquared-nixos-config> { inherit pkgs; }

You can see github:{github-repo}[./default.nix, path=default.nix, rev=master] to see more details but there are general guidelines to the attributes that is contained in this file which is outlined in Channels support section.

Heres an example snippet in a NixOS config making use of my configuration without flakes:

let
  foo-dogsquared-nixos-config = import <foo-dogsquared-nixos-config> { inherit pkgs; };
in {
  imports = [
    foo-dogsquared-nixos-config.modules.programs
    foo-dogsquared-nixos-config.modules.services
    foo-dogsquared-nixos-config.modules.workflows
  ];

  # Still using my GNOME desktop configuration for some reason.
  workflows.workflows.a-happy-gnome.enable = true;
}

With manual fetching

If you really dont want to manage stuff with channels or with flakes for some reason, I suppose you can just use something like github:nmattia/niv/[niv]. You could also pin my config similarly to how you can pin nixpkgs then use it as if you manage it as described from With channels.

Heres a snippet of using it as part of a NixOS configuration.

let
  foo-dogsquared-nixos-config = import (fetchTarball "{canonical-flake-url-tarball-specific}") { inherit pkgs; };
in {
  imports = [
    foo-dogsquared-nixos-config.modules.programs
    foo-dogsquared-nixos-config.modules.services
    foo-dogsquared-nixos-config.modules.workflows
  ];

  # Still using my GNOME desktop configuration for some reason.
  workflows.workflows.a-happy-gnome.enable = true;
}