diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..e185414 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,35 @@ +name: Check nix packages +on: + pull_request: + types: [opened, edited, reopened, synchronize] + push: + branches: [master] +jobs: + check: + name: Check Nix + 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 + - name: Build packages + run: nix build .#${{ matrix.theme }}-grub-theme + build: + strategy: + matrix: + theme: [ acheron argenti blackswan dr.ratio hanya huohuo luocha ruanmei sparkle acheron_cn argenti_cn blackswan_cn dr.ratio_cn hanya_cn huohuo_cn luocha_cn ruanmei_cn sparkle_cn ] + name: Build Nix + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v9 + - name: Build packages + run: nix build .#${{ matrix.theme }}-grub-theme \ No newline at end of file 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/README.md b/README.md index d6d7976..38b85ec 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,27 @@ sudo grub-mkconfig -o /boot/grub/grub.cfg ``` 6. Reboot the computer + +### For NixOS users +1. Added flake into your configuration +```nix +inputs.honkai-railway-grub-theme.url = "github:voidlhf/StarRailGrubThemes"; +``` + +2. Set up theme in your configuration +```nix +honkai-railway-grub-theme = { + enable = true; + # Remember + # Theme name should have the same name as in assets/themes directory e.g. Dr.Ratio_cn is correct + # 'theme' field is optional. Default theme is Acheron. + theme = "RuanMei"; +}; +``` + +3. Rebuild your system +4. Reboot computer to see your theme :) + ## Preview ![Acheron](/preview/Acheron.png) ![BlackSwan](/preview/BlackSwan.png) diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..383eb91 --- /dev/null +++ b/default.nix @@ -0,0 +1,27 @@ +{ stdenvNoCC +, lib +, fetchFromGitHub +, theme +}: + +let + themes = builtins.attrNames (builtins.readDir ./assets/themes); +in + +assert builtins.any (x: x == theme) themes; + +stdenvNoCC.mkDerivation { + name = "StarRailGrubThemes"; + + src = ./.; + + installPhase = "cp -r ./assets/themes/${theme} $out"; + + meta = with lib; { + homepage = "https://github.com/voidlhf/StarRailGrubThemes"; + description = "A pack of GRUB2 themes for Honkai: Star Rail"; + license = licenses.gpl3; + maintainers = with maintainers; [ Wittano ]; + platforms = platforms.linux; + }; +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9f8de0a --- /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": 1712791164, + "narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1042fd8b148a9105f3c0aca3a6177fd1d9360ba5", + "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..08d942a --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "A pack of GRUB2 themes for Honkai: Star Rail"; + + 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/themes); + themePackages = builtins.listToAttrs (builtins.map + (theme: { + name = "${pkgs.lib.strings.toLower theme}-grub-theme"; + value = pkgs.callPackage ./default.nix { inherit theme; }; + }) + themeNames); + in + { + packages = { + default = pkgs.callPackage ./default.nix { theme = "Acheron"; }; + } // themePackages; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ nixpkgs-fmt nixd ]; + }; + + nixosModules.default = ./module.nix; + }); +} diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..1a3382e --- /dev/null +++ b/module.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: +with lib; +let + cfg = config.honkai-railway-grub-theme; + themeNames = builtins.attrNames (builtins.readDir ./assets/themes); +in +{ + options = { + honkai-railway-grub-theme = { + enable = mkEnableOption "Enable Honaki Railway GRUB2 theme"; + theme = mkOption { + type = types.enum themeNames; + default = "Acheron"; + example = "Dr.Ratio"; + description = "Selected theme name. IMPORTANT! Theme name must be the same as in assert/themes directory"; + }; + }; + }; + + config = mkIf (cfg.enable) { + boot.loader.grub = { + theme = pkgs.callPackage ./default.nix { theme = cfg.theme; }; + splashImage = ./assets/themes/${cfg.theme}/background.png; + }; + }; +}