/ flake.nix
flake.nix
 1  {
 2    description = "Alfred";
 3  
 4    inputs = {
 5      flake-utils.url = "github:numtide/flake-utils";
 6      nixpkgs.url = "github:NixOs/nixpkgs";
 7      rust-overlay = {
 8        url = "github:oxalica/rust-overlay";
 9        inputs = {
10          nixpkgs.follows = "nixpkgs";
11        };
12      };
13      treefmt-nix = {
14        url = "github:numtide/treefmt-nix";
15        inputs.nixpkgs.follows = "nixpkgs";
16      };
17    };
18  
19    outputs =
20      {
21        self,
22        flake-utils,
23        nixpkgs,
24        rust-overlay,
25        treefmt-nix,
26      }:
27      {
28        nixosModules.default = import ./module.nix;
29      }
30      // flake-utils.lib.eachDefaultSystem (
31        system:
32        let
33          overlays = [ rust-overlay.overlays.default ];
34  
35          nixpkgs-pkgs = import nixpkgs {
36            inherit overlays system;
37          };
38  
39          rustPlatform =
40            with nixpkgs-pkgs;
41            makeRustPlatform {
42              cargo = rust-bin.stable.latest.minimal;
43              rustc = rust-bin.stable.latest.minimal;
44            };
45  
46          treefmtEval = treefmt-nix.lib.evalModule nixpkgs-pkgs ./treefmt.nix;
47  
48          buildInputs = with nixpkgs-pkgs; [
49            openssl
50            sqlite
51          ];
52  
53          nativeBuildInputs = with nixpkgs-pkgs; [
54            pkg-config
55          ];
56        in
57        rec {
58          checks = packages // {
59            formatting = treefmtEval.config.build.check self;
60          };
61  
62          formatter = treefmtEval.config.build.wrapper;
63  
64          devShells.default =
65            with nixpkgs-pkgs;
66            mkShell {
67              inherit nativeBuildInputs;
68  
69              buildInputs = buildInputs ++ [
70                # This fails to build with latest version of `nixpkgs` ;
71                # _c.f._ https://github.com/rust-db/refinery/issues/355 .
72                # refinery-cli
73                rust-bin.stable.latest.default
74              ];
75            };
76  
77          packages.default = rustPlatform.buildRustPackage {
78            pname = "Alfred";
79            version = "0.1";
80  
81            src = self;
82  
83            cargoLock = {
84              lockFile = ./Cargo.lock;
85              # Fixed-output derivation fetcher doesn't support getting `git` dependencies; We have to reference hashes of every one of them.
86              outputHashes = {
87              };
88            };
89  
90            inherit buildInputs nativeBuildInputs;
91          };
92        }
93      );
94  }