mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-23 06:19:00 +00:00
docs/site: write "Using parts of my configuration" chapter
This commit is contained in:
parent
63ebbcb590
commit
ff8451f0b2
136
README.adoc
136
README.adoc
@ -350,142 +350,6 @@ If you edit `./secrets/backup-archive.yaml` for example, it needs one of the key
|
||||
|
||||
|
||||
|
||||
== 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 <<whats-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 link:./modules/nixos/[NixOS modules] and link:./modules/home-manager[home-manager modules]?
|
||||
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 link:./default.nix[`./default.nix`] 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.
|
||||
|
||||
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;
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
=== 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 link:https://github.com/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, subs=attributes]
|
||||
----
|
||||
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;
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
|
||||
|
||||
== TODO
|
||||
|
||||
In order of priority:
|
||||
|
@ -16,7 +16,7 @@
|
||||
** link:./nixos-modules/profiles[Profiles]
|
||||
** link:./nixos-modules/workflows[Workflows]
|
||||
|
||||
* link:./using-parts-of-my-configuration[Using parts of my configuration]
|
||||
* link:{{< relref "./using-parts-of-my-configuration" >}}[Using parts of my configuration]
|
||||
|
||||
* link:{{< relref "./faq" >}}[Frequently asked questions]
|
||||
|
||||
|
136
docs/content/en-US/using-parts-of-my-configuration/index.adoc
Normal file
136
docs/content/en-US/using-parts-of-my-configuration/index.adoc
Normal file
@ -0,0 +1,136 @@
|
||||
---
|
||||
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:../lay-of-the-land/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:../lay-of-the-land/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, subs=attributes]
|
||||
----
|
||||
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;
|
||||
}
|
||||
----
|
Loading…
Reference in New Issue
Block a user