From 14ae5129f6e12fa94263ff8e55102884c29ea93b Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 00:31:56 +0200 Subject: [PATCH 01/10] feat: add nix flake --- .gitignore | 4 +++ assets/splash_image.jpg | Bin 0 -> 33330 bytes default.nix | 28 ++++++++++++++++++ flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 40 ++++++++++++++++++++++++++ module.nix | 28 ++++++++++++++++++ 6 files changed, 161 insertions(+) create mode 100644 .gitignore create mode 100644 assets/splash_image.jpg create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 module.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39dd1c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.envrc +.direnv +.vscode +result \ No newline at end of file diff --git a/assets/splash_image.jpg b/assets/splash_image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5a144bb81f512199b9c553c48b829f5f9f622ea0 GIT binary patch literal 33330 zcmeIwIZPB$9LMqZW@Zmo3x><1akvzW8WvCiV+bH1+bAoZ9SE)vV_aZCOiTc8JG`|6 zFSJ9&s}jYt!xOL(Z>_*v3ddOyP#cVm&G-N24P`!~#yu;^NC;GwulE@Ro_xczI5*#@NlQwcVfX{Z>&mO^ zjQK`-y32ela;#Bfm!e2%JyIF2(KjVHLXoPfXsXSoX;$}U>$}i&TUfL^%N|}>?1=G4BsVlQ zJ7crkIwHMY{c$NJm5m{;s0kA%O^%;BEg^Aw>g+jl)6z3?7UbsTFD&pZDO$R0`HGdR zR+pBo@vSYdsHzUs)NZWXv}NnI?K^hv+P!D*zWoOd9y)xa<>;~FCr-AWI(_Esx%TrH zE?&BP^;+lk8#iy=zH|59{Ra;pb@%l4J$?54#miT(-@F}o_x{7jPoKYh9Sr7@LLIrX zpd`R7VWl&WfeM#{oygm4bF({rslSekk}M&e`HBzmn$kR zwJ&}k80|;0zYEs*Psv7tjpphV<5g+>JXIH&!W5Z<2`%+5Hg|vl3}65Q7{CAqFn|FJ zU;qOczyJm?fB_6(00S7n00uCC0SsUO0~o*n1~7mD3}65Q7{CAqFn|FJU;qOczyJm? zfB_6(00S7n00uCC0SsUO0~o*n1~7mD3}65Q7{CAqFn|FJU;qOczyJm?fB_6(00S7n z00uCC0SsUO0~o*n1~7mD3}65Q7{CAqFn|FJU;qOczyJm?fB_6(00S7n00uCC0SsUO L1OM4TrrGly1Pv!| literal 0 HcmV?d00001 diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..af712e1 --- /dev/null +++ b/default.nix @@ -0,0 +1,28 @@ +{ stdenvNoCC, lib, theme }: +let + themes = builtins.map (theme: (builtins.head (lib.strings.splitString "." theme))) (builtins.attrNames (builtins.readDir ./assets/backgrounds)); +in +assert builtins.any (x: x == theme) themes; + +stdenvNoCC.mkDerivation { + name = "distro-grub-themes"; + src = ./.; + + installPhase = '' + mkdir -p $out + cp ./assets/backgrounds/${theme}.png $out/background.png + cp ./assets/splash_image.jpg $out/splash_image.jpg + cp -r ./assets/icons $out + cp -r ./assets/fonts/. $out + cp -r ./assets/menu/. $out + cp -r ./assets/theme.txt $out + ''; + + meta = with lib; { + homepage = "https://github.com/AdisonCavani/distro-grub-themes"; + description = "A pack of GRUB2 themes for each Linux distribution"; + license = licenses.gpl3; + maintainers = with maintainers; [ zakuciael ]; + platforms = platforms.linux; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a4dfd23 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712963716, + "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..09a3916 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + description = "A pack of GRUB2 themes for each Linux distribution"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { self, nixpkgs, flake-utils }: + let + systems = [ "aarch64-linux" "i686-linux" "x86_64-linux" ]; + in + flake-utils.lib.eachSystem systems ( + system: + let + pkgs = import nixpkgs { inherit system; }; + themeNames = builtins.attrNames (builtins.readDir ./assets/backgrounds); + themePackages = builtins.listToAttrs (builtins.map + (theme: + let name = (builtins.head (pkgs.lib.strings.splitString "." theme)); in { + name = name + "-grub-theme"; + value = pkgs.callPackage ./default.nix { theme = name; }; + }) + themeNames); + in + { + packages = { + default = pkgs.callPackage ./default.nix { theme = "nixos"; }; + } // themePackages; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ nixd nixpkgs-fmt act jq ]; + }; + + nixosModules.default = ./module.nix; + } + ); +} + \ No newline at end of file diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..7435098 --- /dev/null +++ b/module.nix @@ -0,0 +1,28 @@ +{ pks, lib, config, ... }: +with lib; +let + cfg = config.distro-grub-themes; + themes = builtins.map (theme: (builtins.head (lib.strings.splitString "." theme))) (builtins.attrNames (builtins.readDir ./assets/backgrounds)); +in +{ + options.distro-grub-themes = { + enable = mkEnableOption "Enable Distro Grub Theme"; + theme = mkOption { + type = types.enum themes; + default = "nixos"; + example = "arch-linux"; + description = '' + Selected theme name. + IMPORTANT! Theme name must be the same as in assert/backgrounds directory without the extension + ''; + }; + }; + + config = mkIf (cfg.enable) + { + boot.loader.grub = { + theme = pkgs.callPackage ./default.nix { theme = cfg.theme; }; + splashImage = ./assets/splash_image.jpg; + }; + }; +} From 0159131956078c0440d25df77ea0037de8899b3a Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 00:36:14 +0200 Subject: [PATCH 02/10] ci: add workflow for checking nix packages --- .github/workflows/nix.yml | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..a6e5aad --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,47 @@ +name: Check nix packages +on: + pull_request: + push: + branches: [master] +jobs: + flake: + name: Check flake + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check Nix flake inputs + uses: DeterminateSystems/flake-checker-action@v5 + with: + send-statistics: false + fail-mode: true + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v9 + - name: Check repository + run: nix flake check + matrix: + name: Generate build matrix + runs-on: ubuntu-latest + outputs: + themes: ${{ steps.generate-matrix.outputs.themes }} + steps: + - uses: actions/checkout@v4 + - name: Generate matrix + id: generate-matrix + run: | + THEMES=$(ls assets/backgrounds/ | sed 's/\.png$//g' | jq --raw-input | jq --slurp -c) + echo "themes=$THEMES" >> $GITHUB_OUTPUT + build: + name: Check nix build for theme ${{ matrix.theme }} + runs-on: ubuntu-latest + needs: + - matrix + strategy: + matrix: + theme: ${{ fromJSON(needs.matrix.outputs.themes) }} + steps: + - uses: actions/checkout@v4 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v9 + - name: Build package + run: nix build .#${{ matrix.theme }}-grub-theme + From 08324f165ead711f5ad55cf9c194c4df281b7734 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 03:21:19 +0200 Subject: [PATCH 03/10] docs: add install steps for nix flake --- docs/Installation.mdx | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/docs/Installation.mdx b/docs/Installation.mdx index ddd4e58..477f8d7 100644 --- a/docs/Installation.mdx +++ b/docs/Installation.mdx @@ -84,6 +84,81 @@ sudo eopkg install grub-customizer To revert back to the orignal KDE Neon theme, open GRUB Customizer, and in the Appearance settings tab, change the theme dropdown back to breeze. +## Installation via Nix Flakes +### Prerequisites +- Nix 2.4 or later +- Experimental features `nix-command` and `flakes` enabled. + - You can achive that by adding the following to your `configuration.nix` and rebuilding your system. + ```nix + nix = { + package = pkgs.nixFlakes; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + ``` + +### NixOS module +To use this theme as a NixOS module, a bare-minimum configuration would be as follows: +`flake.nix`: +```nix +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + distro-grub-themes.url = "github:AdisonCavani/distro-grub-themes"; + }; + outputs = { self, nixpkgs, ... }@inputs: { + nixosConfigurations."default" = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + inputs.distro-grub-themes.nixosModules.${system}.default + ]; + }; + }; +} +``` + +`configuration.nix`: +```nix +{ config, pkgs, lib, ... }: { + distro-grub-themes = { + enable = true; + theme = ""; + }; +} +``` + +### Standalone setup +To use this theme in a standalone setup, a bare-minimum configuration would be as follows: +`flake.nix`: +```nix +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + distro-grub-themes.url = "github:AdisonCavani/distro-grub-themes"; + }; + outputs = { self, nixpkgs, ... }@inputs: { + nixosConfigurations."default" = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + ]; + }; + }; +} +``` +`configuration.nix`: +```nix +{ config, pkgs, lib, inputs, ... }: { + + boot.loader.grub = rec { + theme = inputs.distro-grub-themes.packages.${system}.-grub-theme; + splashImage = "${theme}/splash_image.jpg"; + }; +} +``` + ## Manual Installation In order to clone the repository from GitHub, you have to install Git, via the `git` package. From 10c11911304ffb4e7a929845864a55f6088c4eb7 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 03:30:59 +0200 Subject: [PATCH 04/10] ci(nix): restrict checks to only run on nix files --- .github/workflows/nix.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index a6e5aad..9291995 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -3,6 +3,9 @@ on: pull_request: push: branches: [master] + paths: + - "./*.nix" + - ".github/workflows/nix.yml" jobs: flake: name: Check flake From ef292b903fd5149f02749c5035f06659903ed2d2 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 03:32:06 +0200 Subject: [PATCH 05/10] ci(nix): run checks if src changes --- .github/workflows/nix.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 9291995..bfb3f15 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -6,6 +6,8 @@ on: paths: - "./*.nix" - ".github/workflows/nix.yml" + - "assets/**" + - "customize/**" jobs: flake: name: Check flake From f57459404fe5cd297872c8996bf3f3fe68a1f1b9 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 03:33:30 +0200 Subject: [PATCH 06/10] ci(nix): restrict pull request to nix files and src --- .github/workflows/nix.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index bfb3f15..f572cc9 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,6 +1,11 @@ name: Check nix packages on: pull_request: + paths: + - "./*.nix" + - ".github/workflows/nix.yml" + - "assets/**" + - "customize/**" push: branches: [master] paths: From d2ff7f7653c467adf61be22a91a6af8c13bb615a Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 03:54:23 +0200 Subject: [PATCH 07/10] docs(nix): add file names using code titles --- docs/Installation.mdx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/Installation.mdx b/docs/Installation.mdx index 477f8d7..504ec87 100644 --- a/docs/Installation.mdx +++ b/docs/Installation.mdx @@ -99,9 +99,8 @@ sudo eopkg install grub-customizer ``` ### NixOS module -To use this theme as a NixOS module, a bare-minimum configuration would be as follows: -`flake.nix`: -```nix +To use this theme as a NixOS module, a bare-minimum configuration would be as follows: +```nix:flake.nix { inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; @@ -119,8 +118,7 @@ To use this theme as a NixOS module, a bare-minimum configuration would be as fo } ``` -`configuration.nix`: -```nix +```nix:configuration.nix { config, pkgs, lib, ... }: { distro-grub-themes = { enable = true; @@ -130,9 +128,8 @@ To use this theme as a NixOS module, a bare-minimum configuration would be as fo ``` ### Standalone setup -To use this theme in a standalone setup, a bare-minimum configuration would be as follows: -`flake.nix`: -```nix +To use this theme in a standalone setup, a bare-minimum configuration would be as follows: +```nix:flake.nix { inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; @@ -148,8 +145,7 @@ To use this theme in a standalone setup, a bare-minimum configuration would be a }; } ``` -`configuration.nix`: -```nix +```nix:configuration.nix { config, pkgs, lib, inputs, ... }: { boot.loader.grub = rec { From cd79d7012d089e8b3e6c518f3123ead46e0c1b01 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 03:57:21 +0200 Subject: [PATCH 08/10] docs(nix): re-word prerequisites section --- docs/Installation.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Installation.mdx b/docs/Installation.mdx index 504ec87..0d46782 100644 --- a/docs/Installation.mdx +++ b/docs/Installation.mdx @@ -88,8 +88,9 @@ sudo eopkg install grub-customizer ### Prerequisites - Nix 2.4 or later - Experimental features `nix-command` and `flakes` enabled. - - You can achive that by adding the following to your `configuration.nix` and rebuilding your system. - ```nix + - You can achive that by setting the following options and rebuilding your system. + + ```nix:configuration.nix nix = { package = pkgs.nixFlakes; extraOptions = '' From 6b9733172a83dbeaf8262d6f67d318ce997ff684 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Mon, 15 Apr 2024 07:54:34 +0200 Subject: [PATCH 09/10] docs(nix): fix standalone setup example --- docs/Installation.mdx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/Installation.mdx b/docs/Installation.mdx index 0d46782..1fe511b 100644 --- a/docs/Installation.mdx +++ b/docs/Installation.mdx @@ -139,6 +139,12 @@ To use this theme in a standalone setup, a bare-minimum configuration would be a outputs = { self, nixpkgs, ... }@inputs: { nixosConfigurations."default" = nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; + + specialArgs = { + # Pass system and inputs to the configuration.nix file + inherit system inputs; + }; + modules = [ ./configuration.nix ]; @@ -147,7 +153,7 @@ To use this theme in a standalone setup, a bare-minimum configuration would be a } ``` ```nix:configuration.nix -{ config, pkgs, lib, inputs, ... }: { +{ config, pkgs, lib, inputs, system, ... }: { boot.loader.grub = rec { theme = inputs.distro-grub-themes.packages.${system}.-grub-theme; From 768d066516142ac9eeebdb4c4a8201309d380461 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Tue, 16 Apr 2024 16:18:57 +0200 Subject: [PATCH 10/10] chore(nix): move build files to `build/` directory --- default.nix => build/default.nix | 4 ++-- module.nix => build/module.nix | 2 +- flake.nix | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) rename default.nix => build/default.nix (88%) rename module.nix => build/module.nix (89%) diff --git a/default.nix b/build/default.nix similarity index 88% rename from default.nix rename to build/default.nix index af712e1..1cdaf37 100644 --- a/default.nix +++ b/build/default.nix @@ -1,12 +1,12 @@ { stdenvNoCC, lib, theme }: let - themes = builtins.map (theme: (builtins.head (lib.strings.splitString "." theme))) (builtins.attrNames (builtins.readDir ./assets/backgrounds)); + themes = builtins.map (theme: (builtins.head (lib.strings.splitString "." theme))) (builtins.attrNames (builtins.readDir ./../assets/backgrounds)); in assert builtins.any (x: x == theme) themes; stdenvNoCC.mkDerivation { name = "distro-grub-themes"; - src = ./.; + src = ./../.; installPhase = '' mkdir -p $out diff --git a/module.nix b/build/module.nix similarity index 89% rename from module.nix rename to build/module.nix index 7435098..54bdfdd 100644 --- a/module.nix +++ b/build/module.nix @@ -2,7 +2,7 @@ with lib; let cfg = config.distro-grub-themes; - themes = builtins.map (theme: (builtins.head (lib.strings.splitString "." theme))) (builtins.attrNames (builtins.readDir ./assets/backgrounds)); + themes = builtins.map (theme: (builtins.head (lib.strings.splitString "." theme))) (builtins.attrNames (builtins.readDir ./../assets/backgrounds)); in { options.distro-grub-themes = { diff --git a/flake.nix b/flake.nix index 09a3916..eb7c4e1 100644 --- a/flake.nix +++ b/flake.nix @@ -20,20 +20,20 @@ (theme: let name = (builtins.head (pkgs.lib.strings.splitString "." theme)); in { name = name + "-grub-theme"; - value = pkgs.callPackage ./default.nix { theme = name; }; + value = pkgs.callPackage ./build/default.nix { theme = name; }; }) themeNames); in { packages = { - default = pkgs.callPackage ./default.nix { theme = "nixos"; }; + default = pkgs.callPackage ./build/default.nix { theme = "nixos"; }; } // themePackages; devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ nixd nixpkgs-fmt act jq ]; }; - nixosModules.default = ./module.nix; + nixosModules.default = ./build/module.nix; } ); }