# Flake-programs-sqlite: fixing command-not-found for pure flake systems

**URL:** https://discourse.nixos.org/t/flake-programs-sqlite-fixing-command-not-found-for-pure-flake-systems/27669
**Category:** Announcements
**Created:** [April 27, 2023, 6:51pm UTC](https://discourse.nixos.org/t/flake-programs-sqlite-fixing-command-not-found-for-pure-flake-systems/27669 "2023-04-27T18:51:48Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![wamserma](https://discourse.nixos.org/user_avatar/discourse.nixos.org/wamserma/32/5353_2.png) [@wamserma](https://discourse.nixos.org/u/wamserma)
#### Post date: [April 27, 2023, 6:51pm UTC](https://discourse.nixos.org/t/flake-programs-sqlite-fixing-command-not-found-for-pure-flake-systems/27669/1 "2023-04-27T18:51:48Z")

</div>

Hey everyone,  
happy to introduce [flake-programs-sqlite](https://github.com/wamserma/flake-programs-sqlite), a simple flake to automagically specify `programs.sqlite` for `command-not-found`.

## Why?

NixOS systems configured with flakes often don’t have a channel set (e.g. `nix-channel --list` shows no channel), which usually results in a broken `command-not-found` as the command database is part of the channel system and not part of `nixpkgs`.  
Up to now the only option was to use [nix-index](https://github.com/bennofs/nix-index#usage-as-a-command-not-found-replacement), but it was not possible to get back the UX known from channels. ([see here](https://discourse.nixos.org/t/how-to-specify-programs-sqlite-for-command-not-found-from-flakes/22722))

With [flake-programs-sqlite](https://github.com/wamserma/flake-programs-sqlite) a working `command-not-found` only requires a few additions to a flake based system configuration.

## How?

[flake-programs-sqlite](https://github.com/wamserma/flake-programs-sqlite) makes use of a mapping from git commit hashes to channel names. This mapping is updated by a GitHub action by scraping {channels,releases}.nixos.org (currently) about every ten minutes.  
When importing [flake-programs-sqlite](https://github.com/wamserma/flake-programs-sqlite), the standard flake mechanism can be used to pin it’s `nixpkgs` input. When the `programs-sqlite` output package is requested, a fixed output derivation for a `programs.sqlite` database matching the revision of the input `nixpkgs` is constructed from the scraped data. The result of this derivation is then injected into `command-not-found`.

## NixOS Module Integration

Using [flake-programs-sqlite](https://github.com/wamserma/flake-programs-sqlite) as a module in your NixOS configuration is the preferred method. Just add it to your flake inputs, pass it to your outputs and add it to your list of modules:

```auto
# ... 
inputs.fps.url = "github:wamserma/flake-programs-sqlite";
inputs.fps.inputs.nixpkgs.follows = "nixpkgs";

# ...

outputs = { nixpkgs, fps, ... }: {

    nixosConfigurations.mymachine = nixpkgs.lib.nixosSystem {
      modules =
        [
          (import configuration.nix)
          fps.nixosModules.programs-sqlite
          # ...
        ];
    };

```

## Contribute

Feel free to submit issues or pull requests on the [GitHub repository](https://github.com/wamserma/flake-programs-sqlite).

## Note

Scraping started on 21st December 2022. If a certain channel revision is missing, follow the [README](https://github.com/wamserma/flake-programs-sqlite/README.md) for instructions on scraping or [open an issue](https://github.com/wamserma/flake-programs-sqlite/issues).

---

_[View the full topic](https://discourse.nixos.org/t/flake-programs-sqlite-fixing-command-not-found-for-pure-flake-systems/27669)._
