Nix · 2583 bytes Raw Blame History
1 {
2 description = "FORTRESS - A command-line file explorer written in modern Fortran";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 flake-utils.url = "github:numtide/flake-utils";
7 };
8
9 outputs = { self, nixpkgs, flake-utils }:
10 flake-utils.lib.eachDefaultSystem (system:
11 let
12 pkgs = nixpkgs.legacyPackages.${system};
13
14 fortress = pkgs.stdenv.mkDerivation rec {
15 pname = "fortress";
16 version = "1.0.2";
17
18 src = ./.;
19
20 nativeBuildInputs = with pkgs; [
21 gfortran
22 fortran-fpm
23 makeWrapper
24 ];
25
26 buildInputs = with pkgs; [
27 ncurses
28 ];
29
30 buildPhase = ''
31 # fpm needs a writable home for cache
32 export HOME=$(mktemp -d)
33 fpm build --flag "-O2"
34 '';
35
36 installPhase = ''
37 # Install binary to lib directory
38 mkdir -p $out/lib/fortress
39 cp build/gfortran_*/app/fortress $out/lib/fortress/fortress
40
41 # Create wrapper script in bin
42 mkdir -p $out/bin
43 makeWrapper $out/lib/fortress/fortress $out/bin/fortress
44
45 # Install shell integration files
46 mkdir -p $out/share/fortress
47 cp fortress.sh $out/share/fortress/
48 cp fortress.fish $out/share/fortress/
49
50 # Patch fortress.sh to find binary in nix store
51 substituteInPlace $out/share/fortress/fortress.sh \
52 --replace '/usr/lib/fortress/fortress' "$out/lib/fortress/fortress"
53
54 # Install docs
55 mkdir -p $out/share/doc/fortress
56 cp README.md $out/share/doc/fortress/
57 [ -f USAGE.md ] && cp USAGE.md $out/share/doc/fortress/ || true
58 '';
59
60 meta = with pkgs.lib; {
61 description = "A command-line file explorer written in modern Fortran with fzf integration";
62 homepage = "https://github.com/FortranGoingOnForty/fortress";
63 license = licenses.mit;
64 platforms = platforms.unix;
65 mainProgram = "fortress";
66 };
67 };
68 in
69 {
70 packages = {
71 default = fortress;
72 fortress = fortress;
73 };
74
75 apps.default = {
76 type = "app";
77 program = "${fortress}/bin/fortress";
78 };
79
80 devShells.default = pkgs.mkShell {
81 buildInputs = with pkgs; [
82 gfortran
83 fortran-fpm
84 ncurses
85 fzf
86 git
87 ];
88 };
89 }
90 );
91 }