From 73254cd0d35a9700171112b99a56d529cdfdda2d Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 9 May 2024 12:03:13 +0100 Subject: [PATCH] switch to nix-starter-configs --- flake.lock | 15 ++- flake.nix | 105 ++++++++++++++++-- {hosts/default => home-manager}/home.nix | 0 hosts/default/themes/sddm-sugar-candy.nix | 18 --- modules/home-manager/default.nix | 0 {hosts/default => nixos}/configuration.nix | 50 +++++++-- .../hardware-configuration.nix | 0 overlays/default.nix | 23 ++++ pkgs/default.nix | 6 + pkgs/sddm-sugar-candy.nix | 16 +++ .../scripts => pkgs}/wallpaper_changer.nix | 0 11 files changed, 195 insertions(+), 38 deletions(-) rename {hosts/default => home-manager}/home.nix (100%) delete mode 100644 hosts/default/themes/sddm-sugar-candy.nix create mode 100644 modules/home-manager/default.nix rename {hosts/default => nixos}/configuration.nix (54%) rename {hosts/default => nixos}/hardware-configuration.nix (100%) create mode 100644 overlays/default.nix create mode 100644 pkgs/default.nix create mode 100644 pkgs/sddm-sugar-candy.nix rename {hosts/default/scripts => pkgs}/wallpaper_changer.nix (100%) diff --git a/flake.lock b/flake.lock index 6cf4b9c..9bfd4ea 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,18 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", + "path": "/nix/store/3pif36ks3f56py4wb1dkq6sh0nkf3ygj-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-unstable": { "locked": { "lastModified": 1714906307, "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", @@ -39,7 +51,8 @@ "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" } } }, diff --git a/flake.nix b/flake.nix index 61ac7dd..74f4fa7 100644 --- a/flake.nix +++ b/flake.nix @@ -1,25 +1,106 @@ +#{ +# description = "Nixos config flake"; +# +# inputs = { +# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; +# +# home-manager = { +# url = "github:nix-community/home-manager"; +# inputs.nixpkgs.follows = "nixpkgs"; +# }; +# }; +# +# outputs = { self, nixpkgs, ... }@inputs: { +# nixosConfigurations = { +# default = nixpkgs.lib.nixosSystem { +# system = "x86_64-linux"; +# specialArgs = {inherit inputs;}; +# modules = [ +# ./configuration.nix +# ./hosts/default +# #./nixos_modules +# ]; +# }; +# }; +# #homeManagerModules.default = ./homeManager_modules; +# }; +#} { - description = "Nixos config flake"; + description = "Your new nix config"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + # Nixpkgs + #nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + # You can access packages and modules from different nixpkgs revs + # at the same time. Here's an working example: + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # Home manager + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, ... }@inputs: { - nixosConfigurations = { + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + # Supported systems for your flake packages, shell, etc. + systems = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + # This is a function that generates an attribute by calling a function you + # pass to it, with each system as an argument + forAllSystems = nixpkgs.lib.genAttrs systems; + in { + # Your custom packages + # Accessible through 'nix build', 'nix shell', etc + packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); + # Formatter for your nix files, available through 'nix fmt' + # Other options beside 'alejandra' include 'nixpkgs-fmt' + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays {inherit inputs;}; + # Reusable nixos modules you might want to export + # These are usually stuff you would upstream into nixpkgs + nixosModules = import ./modules/nixos; + # Reusable home-manager modules you might want to export + # These are usually stuff you would upstream into home-manager + homeManagerModules = import ./modules/home-manager; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + # FIXME replace with your hostname default = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; + specialArgs = {inherit inputs outputs;}; modules = [ - ./hosts/default/configuration.nix - ./nixos_modules + # > Our main nixos configuration file < + ./nixos/configuration.nix ]; }; }; - homeManagerModules.default = ./homeManager_modules; + +# # Standalone home-manager configuration entrypoint +# # Available through 'home-manager --flake .#your-username@your-hostname' +# homeConfigurations = { +# # FIXME replace with your username@hostname +# "sam" = home-manager.lib.homeManagerConfiguration { +# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance +# extraSpecialArgs = {inherit inputs outputs;}; +# modules = [ +# # > Our main home-manager configuration file < +# ./home-manager/home.nix +# ]; +# }; +# }; }; } diff --git a/hosts/default/home.nix b/home-manager/home.nix similarity index 100% rename from hosts/default/home.nix rename to home-manager/home.nix diff --git a/hosts/default/themes/sddm-sugar-candy.nix b/hosts/default/themes/sddm-sugar-candy.nix deleted file mode 100644 index eb235a9..0000000 --- a/hosts/default/themes/sddm-sugar-candy.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ stdenv, fetchFromGitHub }: -{ - sddm-sugar-candy-theme = stdenv.mkDerivation rec { - pname = "sddm-sugar-candy-theme"; - version = "1.6"; - dontBuild = true; - installPhase = '' - mkdir -p $out/share/sddm/themes - cp -aR $src $out/share/sddm/themes/sugar-candy - ''; - src = fetchFromGitHub { - owner = "Kangie"; - repo = "sddm-sugar-candy"; - rev = "v1.6"; - sha256 = "sha256-p2d7I0UBP63baW/q9MexYJQcqSmZ0L5rkwK3n66gmqM="; - }; - }; -} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/hosts/default/configuration.nix b/nixos/configuration.nix similarity index 54% rename from hosts/default/configuration.nix rename to nixos/configuration.nix index 3d60944..56c2275 100644 --- a/hosts/default/configuration.nix +++ b/nixos/configuration.nix @@ -1,4 +1,4 @@ -{ inputs, config, lib, pkgs, ... }: +{ inputs, config, lib, pkgs, outputs, ... }: { imports = @@ -6,13 +6,46 @@ ./hardware-configuration.nix inputs.home-manager.nixosModules.home-manager ]; + + home-manager = { + extraSpecialArgs = { inherit inputs outputs; }; + users = { + # Import your home-manager configuration + sam = import ../home-manager/home.nix; + }; + }; + + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages - home-manager = { - extraSpecialArgs = { inherit inputs; }; - users = { - sam = import ./home.nix; + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; }; }; + +# home-manager = { +# extraSpecialArgs = { inherit inputs; }; +# users = { +# sam = import ./home.nix; +# }; +# }; nix.settings.experimental-features = [ "nix-command" "flakes" ]; @@ -61,10 +94,13 @@ networkmanagerapplet htop sddm + sshfs-fuse wdisplays - (callPackage ./themes/sddm-sugar-candy.nix{}).sddm-sugar-candy-theme + sddm-sugar-candy-theme + wallpaper_changer + #(callPackage ../../nixos_modules/themes/sddm-sugar-candy.nix{}).sddm-sugar-candy-theme libsForQt5.qt5.qtgraphicaleffects #required for sugar candy - (import ./scripts/wallpaper_changer.nix { inherit pkgs; }) + #(import ../../nixos_modules/scripts/wallpaper_changer.nix { inherit pkgs; }) ]; programs.gnupg.agent = { diff --git a/hosts/default/hardware-configuration.nix b/nixos/hardware-configuration.nix similarity index 100% rename from hosts/default/hardware-configuration.nix rename to nixos/hardware-configuration.nix diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..7bfcb4c --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,23 @@ +# This file defines overlays +{inputs, ...}: { + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs final.pkgs; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..ed084cb --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,6 @@ +# Custom packages, that can be defined similarly to ones from nixpkgs +# You can build them using 'nix build .#example' +pkgs: { + sddm-sugar-candy-theme = pkgs.callPackage ./sddm-sugar-candy.nix { }; + wallpaper_changer = pkgs.callPackage ./wallpaper_changer.nix { }; +} diff --git a/pkgs/sddm-sugar-candy.nix b/pkgs/sddm-sugar-candy.nix new file mode 100644 index 0000000..a31dc79 --- /dev/null +++ b/pkgs/sddm-sugar-candy.nix @@ -0,0 +1,16 @@ +{ pkgs ? import { }, stdenv, fetchFromGitHub }: +pkgs.stdenv.mkDerivation rec { + pname = "sddm-sugar-candy-theme"; + version = "1.6"; + dontBuild = true; + installPhase = '' + mkdir -p $out/share/sddm/themes + cp -aR $src $out/share/sddm/themes/sugar-candy + ''; + src = fetchFromGitHub { + owner = "Kangie"; + repo = "sddm-sugar-candy"; + rev = "v1.6"; + sha256 = "sha256-p2d7I0UBP63baW/q9MexYJQcqSmZ0L5rkwK3n66gmqM="; + }; +} diff --git a/hosts/default/scripts/wallpaper_changer.nix b/pkgs/wallpaper_changer.nix similarity index 100% rename from hosts/default/scripts/wallpaper_changer.nix rename to pkgs/wallpaper_changer.nix