From f0772f9b996ef0359cd597ff1f8abcfc6cd80cce Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Sun, 12 May 2024 20:12:50 +0200 Subject: [PATCH] build(nix): add Nix support --- .gitignore | 1 + default.nix | 48 +++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 +++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 4dd27d0b..e4bb4fb4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ out *.swo *.swp .zsign_cache/ +result diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..b8965954 --- /dev/null +++ b/default.nix @@ -0,0 +1,48 @@ +{ + pkgs ? import {}, + lib ? import , +}: +pkgs.stdenv.mkDerivation rec { + pname = "tildefriends"; + version = "0.0.19"; + + src = pkgs.fetchFromGitea { + domain = "dev.tildefriends.net"; + owner = "cory"; + repo = "tildefriends"; + # rev = "v${version}"; + rev = "47838d5e482cb4aac40190fa0414f08b8cf94d40"; + hash = "sha256-mb5KYvWPIqgV64FOaXKHm2ownBJiiSRtdH8+YWiXwvE="; # 47838d5e482cb4aac40190fa0414f08b8cf94d40 + fetchSubmodules = true; + }; + + nativeBuildInputs = with pkgs; [ + gnumake + openssl + which + ]; + + buildInputs = with pkgs; [ + openssl + which + ]; + + buildPhase = '' + make -j $NIX_BUILD_CORES release + ''; + + installPhase = '' + mkdir -p $out/bin + cp -r out/release/tildefriends $out/bin + ''; + + doCheck = false; + + meta = with pkgs; { + homepage = "https://tildefriends.net"; + description = "Make apps and friends from the comfort of your web browser."; + mainProgram = "tildefriends"; + license = with lib.licenses; [mit]; + platforms = lib.platforms.all; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..0aebcb80 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1715395895, + "narHash": "sha256-DreMqi6+qa21ffLQqhMQL2XRUkAGt3N7iVB5FhJKie4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "71bae31b7dbc335528ca7e96f479ec93462323ff", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..08106c3e --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "Tilde Friends is a platform for making, running, and sharing web applications"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + }; + in rec + { + # Nix formatter, run using `$ nix fmt` + formatter = pkgs.alejandra; + + # Exports the tildefriends package + packages.default = pkgs.callPackage ./default.nix {}; + + # Creates a shell with the necessary dependencies + # Enter using `$ nix develop` + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + openssl + llvmPackages_17.clang-unwrapped + unzip + ]; + }; + }); +}