aboutsummaryrefslogtreecommitdiffhomepage
path: root/flake.nix
blob: 5952538a2b4c7f4280ca6792e44d2270a0d2aaac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
  description = "Decidedly Unimplemented C compiler, a toy C compiler";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

    systems.url = "github:nix-systems/x86_64-linux";

    flake-utils = {
      url = "github:numtide/flake-utils";
      inputs.systems.follows = "systems";
    };

    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
      treefmt-nix,
      ...
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; };
        treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
      in
      {
        packages.default = pkgs.stdenv.mkDerivation {
          pname = "ducc";
          version = "0.1.0";
          src = ./.;
          # Disable some kinds of hardening to disable GCC optimization.
          # cf. https://nixos.wiki/wiki/C#Hardening_flags
          # TODO: provide release build?
          hardeningDisable = [ "fortify" ];
          installPhase = ''
            mkdir -p $out/bin
            cp build/ducc $out/bin
          '';
        };

        devShells.default = pkgs.mkShell {
          packages = [
            pkgs.just
          ];
          # Disable some kinds of hardening to disable GCC optimization.
          # cf. https://nixos.wiki/wiki/C#Hardening_flags
          hardeningDisable = [ "fortify" ];
        };

        formatter = treefmt.config.build.wrapper;
      }
    );
}