{ description = "Main library for my webpage"; inputs = { nixpkgs.url = "github:nixos/nixpkgs"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; nix-filter.url = "github:numtide/nix-filter"; www-assets = { url = "git://git.mathematicaster.org/www/assets.git"; inputs = { nixpkgs.follows = "nixpkgs"; flake-parts.follows = "flake-parts"; }; }; }; outputs = inputs@{self, flake-parts, nixpkgs, nix-filter, ... }: flake-parts.lib.mkFlake { inherit self inputs; } { systems = import inputs.systems; flake.lib = { rubberWith = { pkgs, texPath }: pkgs.symlinkJoin rec { name = "rubber"; nativeBuildInputs = [ pkgs.makeWrapper ]; paths = [ pkgs.rubber ]; postBuild = '' for x in $out/bin/*; do wrapProgram "$x" --prefix PATH : ${pkgs.lib.makeBinPath paths} done ''; }; hakyllWith = { pkgs, site, paths ? [], texPath ? null }: pkgs.symlinkJoin { inherit (site) name; nativeBuildInputs = [ pkgs.makeWrapper ]; paths = [ (pkgs.haskell.lib.compose.justStaticExecutables site) pkgs.rsync ] ++ paths ++ pkgs.lib.optional (texPath != null) (self.lib.rubberWith { inherit pkgs texPath; }); postBuild = '' for x in $out/bin/*; do wrapProgram "$x" --prefix PATH : ${pkgs.lib.makeBinPath paths} done ''; }; }; flake.overlays.default = final: prev: { haskellPackages = prev.haskellPackages.extend (hfinal: _hprev: { www-main = let src = nix-filter { root = ./.; include = [ "src" "app" "templates" "package.yaml" "www-main.cabal" ]; }; in hfinal.callCabal2nix "www-main" src {}; }); }; perSystem = { self', config, pkgs, system, ... }: { _module.args.pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default inputs.www-assets.overlays.default ]; }; # haskellProjects.default = { # projectRoot = ./.; # }; packages = rec { default = www-main-exe; www-main-exe = self.lib.hakyllWith { inherit pkgs; # site = config.packages.www-main; site = pkgs.haskellPackages.www-main; texPath = [ pkgs.texlive.combined.scheme-full ]; }; site = pkgs.runCommandLocal "build-site" {} '' mkdir $out cd $out cp -r ${./data} data cp -r ${./www} www mkdir assets ${www-main-exe}/bin/www-main rebuild ''; deploy = pkgs.writeShellApplication { name = "deploy"; text = '' cd ${site} ${www-main-exe}/bin/www-main deploy ''; }; }; devShells.default = pkgs.haskellPackages.shellFor { packages = _: []; withHoogle = true; buildInputs = with pkgs.haskellPackages; [ cabal-install hpack hlint fast-tags pkgs.haskell-language-server pkgs.zlib pkgs.icu (pkgs.writeShellApplication { name = "site-rebuild"; text = '' nix run ${self}#www-main-exe -- rebuild "''${@}" ''; }) (pkgs.writeShellApplication { name = "site-watch"; text = '' nix run ${self}#www-main-exe -- watch "''${@}" ''; }) (pkgs.writeShellApplication { name = "mkassets"; text = '' toplevel="$(git rev-parse --show-toplevel)" cd "$toplevel" dir="$toplevel/assets" rm -rf "$dir" cp -r "${pkgs.www-assets}" "$dir" ''; }) ]; }; }; }; # outputs = { self, nixpkgs, flake-utils, nix-filter, ... }: { # # overlays.default = import ./nix/overlay.nix { inherit nix-filter; }; # # } // flake-utils.lib.eachDefaultSystem (system: let # pkgs = import nixpkgs { # inherit system; # overlays = [ self.overlays.default ]; # }; # in { # packages = { # inherit (pkgs) www-main; # default = pkgs.www-main; # }; # # devShells.default = pkgs.haskellPackages.shellFor { # packages = _: []; # # packages = p: [ p.www-main ]; # withHoogle = true; # buildInputs = with pkgs.haskellPackages; [ # cabal-install # hpack # hlint # fast-tags # pkgs.haskell-language-server # pkgs.zlib # pkgs.icu # ]; # }; # }); }