mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 10:58:02 +00:00
137 lines
4.6 KiB
Plaintext
137 lines
4.6 KiB
Plaintext
---
|
|
title: Using parts of my configuration
|
|
---
|
|
= Using parts of my configuration
|
|
|
|
Hey there, stranger.
|
|
Wanted to try parts of my configuration but don't want to copy it outright since you're feeling lazy or what-have-you?
|
|
I made my configuration to be easy to use and integrate into your system.
|
|
|
|
Here's how...
|
|
|
|
|
|
[#using-my-config-with-flakes]
|
|
== 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.
|
|
|
|
[source, nix, subs=attributes]
|
|
----
|
|
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 xref:../02-lay-of-the-land/03-whats-in-my-flake/index.adoc[What's in my flake?].
|
|
|
|
For example, you could make use of my packages by adding them as an overlay which is recommended if you're going to use my NixOS modules anyways.
|
|
Here's one way to put as part of your NixOS configuration...
|
|
|
|
[source, nix]
|
|
----
|
|
{
|
|
nixpkgs.overlays = [
|
|
inputs.foo-dogsquared-nixos-config.overlays.default
|
|
];
|
|
}
|
|
----
|
|
|
|
...or import them as part of nixpkgs.
|
|
|
|
[source, nix]
|
|
----
|
|
import nixpkgs {
|
|
system = "x86_64-linux";
|
|
overlays = [
|
|
inputs.foo-dogsquared-nixos-config.overlays.default
|
|
];
|
|
}
|
|
----
|
|
|
|
If you're going to use my stuff, why don't 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.
|
|
|
|
[source, nix]
|
|
----
|
|
{
|
|
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;
|
|
}
|
|
----
|
|
|
|
|
|
[#using-my-config-with-channels]
|
|
== With channels
|
|
|
|
The traditional way of managing stuff with link:https://nixos.org/manual/nix/stable/package-management/channels.html[channels].
|
|
Though, I have made some efforts to make it easy to use without flakes, I cannot guarantee it's good compared to using it with flakes.
|
|
|
|
WARNING: You cannot install my NixOS configurations at all with channels so there's 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...
|
|
|
|
[source, shell, subs=attributes]
|
|
----
|
|
nix-channel --add "{canonical-flake-url-tarball-master}" foo-dogsquared-nixos-config
|
|
nix-channel --update
|
|
----
|
|
|
|
...then import my config as part of your configuration.
|
|
|
|
[source, nix]
|
|
----
|
|
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 xref:../02-lay-of-the-land/04-channels-support/index.adoc[Channels support] section.
|
|
|
|
Here's an example snippet in a NixOS config making use of my configuration without flakes:
|
|
|
|
[source, nix]
|
|
----
|
|
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;
|
|
}
|
|
----
|
|
|
|
|
|
[#using-manual-fetching]
|
|
== With manual fetching
|
|
|
|
If you really don't 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 link:https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs[how you can pin nixpkgs] then use it as if you manage it as described from <<using-my-config-with-channels>>.
|
|
|
|
Here's a snippet of using it as part of a NixOS configuration.
|
|
|
|
[source, nix]
|
|
----
|
|
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;
|
|
}
|
|
----
|