summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 0af88e4863f141879658daa6ef5187af7ba1b38c (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
{
  inputs = {
    teleia.url = "github:lcolonq/teleia";
    nixpkgs.follows = "teleia/nixpkgs";
  };

  outputs = inputs@{ self, nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
      inherit (pkgs) lib;
      src = ./.;
      elfland = inputs.teleia.native.build src "elfland";
      nonnix = pkgs.stdenv.mkDerivation {
        name = "elfland-nonnix";
        phases = [ "installPhase" ];
        installPhase = ''
          mkdir $out
          cp -rv ${elfland}/bin/elfland $out
          chmod +w $out/elfland
          patchelf --remove-rpath $out/elfland
          patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $out/elfland
          strip $out/elfland
          chmod -w $out/elfland
        '';
      };
      windows = inputs.teleia.windows.build src "elfland";
      wasm = inputs.teleia.wasm.buildAtUrlInDir src "elfland" "/" "./crates/elfland";
    in {
      packages.${system} = {
        default = elfland;
        inherit elfland nonnix windows wasm;
      };
      applications.${system}.default = {
        type = "app";
        program = "${elfland}/bin/elfland";
      };
      devShells.${system} = {
        # default = inputs.teleia.shell;
        default = inputs.teleia.shell.overrideAttrs (final: prev: {
          RA_LOG = "rust_analyzer=info";
        });
        windows = inputs.teleia.windows.shell;
      };
      overlay = self: super: {
        elfland = {
          inherit wasm;
        };
      };
    };
}