{ description = "blazingly-fast super-concurrent webscale file server"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; crane.url = "github:ipetkov/crane"; crane.inputs.nixpkgs.follows = "nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, crane, flake-utils }: let description = "blazingly-fast super-concurrent webscale file server"; src = ./.; packages = flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages."${system}"; craneLib = crane.lib.${system}; in rec { packages.u = craneLib.buildPackage { pname = "u"; version = "0.1.0"; # Don't use cleanCargoSource here, as it removes sqlx-data.json src = src; doCheck = false; }; apps.u = flake-utils.lib.mkApp { name = "u"; drv = packages.u; }; packages.u-upload = pkgs.stdenv.mkDerivation rec { name = "u-upload"; src = (pkgs.writeScriptBin "u-upload" (builtins.readFile ./upload.sh)); buildInputs = with pkgs; [ curl jq xclip ]; nativeBuildInputs = with pkgs; [ makeWrapper ]; installPhase = '' mkdir -p $out/bin cp bin/u-upload $out/bin wrapProgram $out/bin/u-upload \ --prefix PATH : ${pkgs.lib.makeBinPath buildInputs} ''; }; devShell = pkgs.mkShell { inputsFrom = [ packages.u ]; nativeBuildInputs = with pkgs; [ rustc cargo rust-analyzer sqlx-cli packages.u-upload ]; }; }); in packages // { nixosModule = { config, lib, pkgs, ... }: with lib; let cfg = config.services.u; pkg = self.packages.${pkgs.system}.u; in { options.services.u = { enable = mkEnableOption description; user = mkOption { type = types.str; default = "u"; }; group = mkOption { type = types.str; default = "u"; }; port = mkOption { type = types.int; default = 8075; }; }; config = mkIf cfg.enable { systemd.services.u = { description = description; wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; preStart = '' cat > /var/lib/u/.env <