Unverified Commit 83604aae authored by yaya's avatar yaya Committed by GitHub
Browse files

command-not-found: enable and default to channel release's dbPath (#489532)

parents 81544468 93e8c9e1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -109,6 +109,8 @@

- `nodePackages.browserify` has been removed, as it was unmaintained within nixpkgs.

- `command-not-found` package will be enabled by default if the source of nixpkgs contains the file `programs.sqlite`. This is the case if a nixpkgs tarball from https://channels.nixos.org is used. This usage will also make the database of `command-no-found` stateless.

- `nodePackages.sass` has been removed, as it was unmaintained within nixpkgs.

- All `@tailwindcss` packages in the `nodePackages` set have been removed, as they are libraries that should instead be locked by JS projects that utilize them.
+33 −25
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@ in
        Whether interactive shells should show which Nix package (if
        any) provides a missing command.

        Requires nix-channels to be set and downloaded (sudo nix-channel --update.)

        See also nix-index and nix-index-database as an alternative for flakes-based systems.

        Additionally, having the env var NIX_AUTO_RUN set will automatically run the matching package, and with NIX_AUTO_RUN_INTERACTIVE it will confirm the package before running.
@@ -47,18 +45,28 @@ in
    };

    dbPath = lib.mkOption {
      default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite";
      description = ''
        Absolute path to programs.sqlite.
        Absolute path to `programs.sqlite`, which contains mappings from binary names to package names.

        If a nixpkgs tarball from https://channels.nixos.org is used as the source of nixpkgs, this file will be provided and this option be set by default.

        By default this file will be provided by your channel
        (nixexprs.tar.xz).
        To use the stateful `programs.sqlite` database, set this option to
        `/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite`.
        If you do so, you can update it with `sudo nix-channels --update`.
      '';
      type = lib.types.path;
    };
  };

  config = lib.mkIf cfg.enable {
  config = lib.mkMerge [
    {
      programs.command-not-found = {
        enable = lib.mkOptionDefault (builtins.pathExists cfg.dbPath);
        dbPath = pkgs.path + "/programs.sqlite";
      };
    }

    (lib.mkIf cfg.enable {
      programs.bash.interactiveShellInit = ''
        command_not_found_handle() {
          '${commandNotFound}/bin/command-not-found' "$@"
@@ -79,6 +87,6 @@ in
      '';

      environment.systemPackages = [ commandNotFound ];
  };

    })
  ];
}