From 8c25c964da9d908358103a8350d9967202fd919f Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 6 Apr 2024 05:48:42 -0400 Subject: [PATCH] feat: Add example config Will extend upon this later, but this basically makes it possible to guarantee that the flake can be used inside another flake and be customized as expected. Note that hardware-configuration.nix is optional if you're just using the configuration for virtual machines and containers, which is why it's optional here. A default file isn't provided to help users understand that they have to bring their own. --- example/configuration.nix | 43 +++++++++++++++++++++++++++++++++++++++ example/flake.nix | 25 +++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 example/configuration.nix create mode 100644 example/flake.nix diff --git a/example/configuration.nix b/example/configuration.nix new file mode 100644 index 00000000..18a76976 --- /dev/null +++ b/example/configuration.nix @@ -0,0 +1,43 @@ +{ nix-config, pkgs, ... }: + +let + inherit (builtins) attrValues; +in +{ + imports = attrValues { + inherit (nix-config.nixosModules) system shell; + + customConfig = { + modules.system.username = "demo"; + }; + }; + + home-manager.sharedModules = attrValues { + inherit (nix-config.homeManagerModules) yazi; + + youCanNameThisAnything = { + programs.btop.enable = true; + }; + }; + + environment.systemPackages = attrValues { + inherit (nix-config.packages.x86_64-linux) webp-thumbnailer; + + inherit (pkgs) ruby php; + }; + + nixpkgs.overlays = attrValues { + inherit (nix-config.overlays) kitty; + + exampleOverlay = final: prev: { + btop = prev.btop.overrideAttrs (oldAttrs: { + postInstall = (oldAttrs.postInstall or "") + /* bash */ '' + echo "#!/usr/bin/env sh" >> btop-overlay + echo "echo 'hello world'" >> btop-overlay + + install -Dm755 btop-overlay $out/bin/btop-overlay + ''; + }); + }; + }; +} diff --git a/example/flake.nix b/example/flake.nix new file mode 100644 index 00000000..8d1d924a --- /dev/null +++ b/example/flake.nix @@ -0,0 +1,25 @@ +{ + description = "An example of creating your own flake that extends this nix-config"; + + inputs = { + nix-config.url = "github:donovanglover/nix-config"; + }; + + outputs = { nix-config, ... } @ attrs: + let + inherit (nix-config.inputs) nixpkgs; + inherit (nixpkgs.lib) nixosSystem optional; + inherit (builtins) pathExists; + in + { + nixosConfigurations = { + hyprland = nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs; + modules = [ + ./configuration.nix + ] ++ optional (pathExists ./hardware-configuration.nix) ./hardware-configuration.nix; + }; + }; + }; +}