diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cc3a13a..3f5fb0b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,13 +3,12 @@ updates: - package-ecosystem: "github-actions" directory: "/" commit-message: - prefix: ⬆️ + prefix: "⬆️ " schedule: interval: "monthly" - - package-ecosystem: "cargo" directory: "/" commit-message: - prefix: ⬆️ + prefix: "⬆️ " schedule: interval: "monthly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5277d7c..a5114f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,33 +1,31 @@ name: "ci" - on: workflow_dispatch: # allows manual triggering pull_request: - branches: [ main ] + branches: [main] paths-ignore: - '**.md' push: - branches: [ main ] + branches: [main] paths-ignore: - '**.md' merge_group: - jobs: flake-check: runs-on: ubuntu-latest environment: cachix steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Nix Flakes doesn't work on shallow clones - - uses: cachix/install-nix-action@V27 - with: - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v15 - with: - name: friedow - # If you chose API tokens for write access OR if you have a private cache - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: "flake check" - run: nix flake check -Lvv --no-update-lock-file + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Nix Flakes doesn't work on shallow clones + - uses: cachix/install-nix-action@V27 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v15 + with: + name: friedow + # If you chose API tokens for write access OR if you have a private cache + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: "flake check" + run: nix flake check -Lvv --no-update-lock-file diff --git a/flake.nix b/flake.nix index 3c3cab3..f0e4447 100644 --- a/flake.nix +++ b/flake.nix @@ -3,8 +3,7 @@ nixConfig = { extra-substituters = [ "https://friedow.cachix.org" ]; - extra-trusted-public-keys = - [ "friedow.cachix.org-1:JDEaYMqNgGu+bVPOca7Zu4Cp8QDMkvQpArKuwPKa29A=" ]; + extra-trusted-public-keys = [ "friedow.cachix.org-1:JDEaYMqNgGu+bVPOca7Zu4Cp8QDMkvQpArKuwPKa29A=" ]; }; inputs = { @@ -17,12 +16,24 @@ }; }; - outputs = { self, nixpkgs, crane, treefmt-nix, home-manager, ... }: + outputs = + { + self, + nixpkgs, + crane, + treefmt-nix, + home-manager, + ... + }: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; - devInputs = with pkgs; [ rustc rustfmt cargo ]; + devInputs = with pkgs; [ + rustc + rustfmt + cargo + ]; nativeBuildInputs = with pkgs; [ makeWrapper @@ -42,24 +53,32 @@ craneLib = crane.lib.${system}; fontFilter = path: _type: builtins.match ".*ttf$" path != null; configFilter = path: _type: builtins.match ".*config.yml$" path != null; - assetOrCargo = path: type: - (configFilter path type) || (fontFilter path type) - || (craneLib.filterCargoSources path type); + assetOrCargo = + path: type: + (configFilter path type) || (fontFilter path type) || (craneLib.filterCargoSources path type); commonArgs = { src = pkgs.lib.cleanSourceWith { src = craneLib.path ./.; filter = assetOrCargo; }; - inherit pname version buildInputs nativeBuildInputs; + inherit + pname + version + buildInputs + nativeBuildInputs + ; }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; - cargoClippy = craneLib.cargoClippy (commonArgs // { - inherit cargoArtifacts; - cargoClippyExtraArgs = "--all-targets --all-features"; - }); + cargoClippy = craneLib.cargoClippy ( + commonArgs + // { + inherit cargoArtifacts; + cargoClippyExtraArgs = "--all-targets --all-features"; + } + ); GIT_DATE = "${builtins.substring 0 4 self.lastModifiedDate}-${ - builtins.substring 4 2 self.lastModifiedDate - }-${builtins.substring 6 2 self.lastModifiedDate}"; + builtins.substring 4 2 self.lastModifiedDate + }-${builtins.substring 6 2 self.lastModifiedDate}"; GIT_REV = self.shortRev or "Not committed yet."; treefmt = (treefmt-nix.lib.evalModule pkgs ./formatter.nix).config.build; libPath = pkgs.lib.makeLibraryPath [ @@ -69,68 +88,86 @@ pkgs.libGL ]; - in { + in + { devShells.${system}.default = pkgs.mkShell { - inherit nativeBuildInputs buildInputs GIT_DATE GIT_REV; + inherit + nativeBuildInputs + buildInputs + GIT_DATE + GIT_REV + ; packages = devInputs ++ [ treefmt.wrapper ]; LD_LIBRARY_PATH = libPath; }; packages.${system} = { - default = craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts nativeBuildInputs buildInputs pname GIT_REV - GIT_DATE; - postFixup = pkgs.lib.optional pkgs.stdenv.isLinux '' - rpath=$(patchelf --print-rpath $out/bin/${pname}) - patchelf --set-rpath "$rpath:${libPath}" $out/bin/${pname} - ''; + default = craneLib.buildPackage ( + commonArgs + // { + inherit + cargoArtifacts + nativeBuildInputs + buildInputs + pname + GIT_REV + GIT_DATE + ; + postFixup = pkgs.lib.optional pkgs.stdenv.isLinux '' + rpath=$(patchelf --print-rpath $out/bin/${pname}) + patchelf --set-rpath "$rpath:${libPath}" $out/bin/${pname} + ''; - meta = with pkgs.lib; { - description = "Your trusty omnibox search."; - homepage = "https://github.com/friedow/centerpiece"; - platforms = platforms.linux; - license = licenses.mit; - mainProgram = pname; - maintainers = [ "friedow" ]; - }; - }); - index-git-repositories = craneLib.buildPackage (commonArgs // rec { - inherit cargoArtifacts; - pname = "index-git-repositories"; - cargoExtraArgs = "-p ${pname}"; - meta.mainProgram = pname; - }); + meta = with pkgs.lib; { + description = "Your trusty omnibox search."; + homepage = "https://github.com/friedow/centerpiece"; + platforms = platforms.linux; + license = licenses.mit; + mainProgram = pname; + maintainers = [ "friedow" ]; + }; + } + ); + index-git-repositories = craneLib.buildPackage ( + commonArgs + // rec { + inherit cargoArtifacts; + pname = "index-git-repositories"; + cargoExtraArgs = "-p ${pname}"; + meta.mainProgram = pname; + } + ); }; checks.${system} = { - inherit (self.outputs.packages.${system}) - default index-git-repositories; + inherit (self.outputs.packages.${system}) default index-git-repositories; shell = self.outputs.devShells.${system}.default; treefmt = treefmt.check self; inherit cargoClippy; - hmModule = (nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - home-manager.nixosModules.home-manager - { - home-manager.users.alice = { - imports = [ self.outputs.hmModules."x86_64-linux".default ]; - programs.centerpiece = { - enable = true; - config.plugin.git_repositories.commands = [ [ "alacritty" ] ]; - services.index-git-repositories = { + hmModule = + (nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + home-manager.nixosModules.home-manager + { + home-manager.users.alice = { + imports = [ self.outputs.hmModules."x86_64-linux".default ]; + programs.centerpiece = { enable = true; - interval = "3hours"; + config.plugin.git_repositories.commands = [ [ "alacritty" ] ]; + services.index-git-repositories = { + enable = true; + interval = "3hours"; + }; }; + home.stateVersion = "23.11"; + }; + users.users.alice = { + isNormalUser = true; + uid = 1000; + home = "/home/alice"; }; - home.stateVersion = "23.11"; - }; - users.users.alice = { - isNormalUser = true; - uid = 1000; - home = "/home/alice"; - }; - } - ]; - }).config.system.build.vm; + } + ]; + }).config.system.build.vm; }; hmModules.${system}.default = import ./home-manager-module.nix { centerpiece = self.outputs.packages.${system}.default; diff --git a/home-manager-module.nix b/home-manager-module.nix index cd9bfbd..12c4d36 100644 --- a/home-manager-module.nix +++ b/home-manager-module.nix @@ -1,9 +1,15 @@ { index-git-repositories, centerpiece }: -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: let cfg = config.programs.centerpiece; git-index-name = "index-git-repositories"; -in { +in +{ options.programs.centerpiece = { enable = lib.mkEnableOption (lib.mdDoc "Centerpiece"); @@ -77,8 +83,17 @@ in { }; commands = lib.mkOption { default = [ - [ "alacritty" "--command" "nvim" "$GIT_DIRECTORY" ] - [ "alacritty" "--working-directory" "$GIT_DIRECTORY" ] + [ + "alacritty" + "--command" + "nvim" + "$GIT_DIRECTORY" + ] + [ + "alacritty" + "--working-directory" + "$GIT_DIRECTORY" + ] ]; type = lib.types.listOf (lib.types.listOf lib.types.str); description = lib.mdDoc '' @@ -87,9 +102,23 @@ in { Use the $GIT_DIRECTORY_NAME variable to pass in the selected directory name. ''; example = [ - [ "code" "--new-window" "$GIT_DIRECTORY" ] - [ "alacritty" "--command" "lazygit" "--path" "$GIT_DIRECTORY" ] - [ "alacritty" "--working-directory" "$GIT_DIRECTORY" ] + [ + "code" + "--new-window" + "$GIT_DIRECTORY" + ] + [ + "alacritty" + "--command" + "lazygit" + "--path" + "$GIT_DIRECTORY" + ] + [ + "alacritty" + "--working-directory" + "$GIT_DIRECTORY" + ] ]; }; }; @@ -163,8 +192,7 @@ in { enable = lib.mkOption { default = true; type = lib.types.bool; - description = - lib.mdDoc "Enable / disable the git repositories indexer service."; + description = lib.mdDoc "Enable / disable the git repositories indexer service."; }; interval = lib.mkOption { default = "5min"; @@ -184,8 +212,7 @@ in { (lib.mkIf cfg.enable { home.packages = [ centerpiece ]; }) (lib.mkIf cfg.enable { - home.file.".config/centerpiece/config.yml".text = - lib.generators.toYAML { } cfg.config; + home.file.".config/centerpiece/config.yml".text = lib.generators.toYAML { } cfg.config; }) (lib.mkIf cfg.services.index-git-repositories.enable { @@ -198,18 +225,21 @@ in { }; Service = { - ExecStart = "${pkgs.writeShellScript - "${git-index-name}-service-ExecStart" '' - exec ${lib.getExe index-git-repositories} - ''}"; + ExecStart = "${pkgs.writeShellScript "${git-index-name}-service-ExecStart" '' + exec ${lib.getExe index-git-repositories} + ''}"; Type = "oneshot"; }; }; }; timers = { index-git-repositories-timer = { - Unit = { Description = "Activate the git repository indexer"; }; - Install = { WantedBy = [ "timers.target" ]; }; + Unit = { + Description = "Activate the git repository indexer"; + }; + Install = { + WantedBy = [ "timers.target" ]; + }; Timer = { OnUnitActiveSec = cfg.services.index-git-repositories.interval; OnBootSec = "0min";