From cf4411bd7ceb5d3af482faabcdaf6bfa9b7ae214 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Thu, 26 Sep 2024 01:03:54 +0500 Subject: [PATCH] initial commit --- .gitignore | 5 ++ flake.lock | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 300 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..012adb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target +result* +/temp +/.direnv +.env diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a8df878 --- /dev/null +++ b/flake.lock @@ -0,0 +1,149 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1725409566, + "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "dream2nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "purescript-overlay": "purescript-overlay", + "pyproject-nix": "pyproject-nix" + }, + "locked": { + "lastModified": 1726523340, + "narHash": "sha256-Av5mdR2lAGUVdA6DJ8Anon3/FZg3DX4gl1Ff72rCpKU=", + "owner": "nix-community", + "repo": "dream2nix", + "rev": "b76c529f377100516c40c5b6e239a4525fdcabe0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "dream2nix", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": [] + }, + "locked": { + "lastModified": 1726986637, + "narHash": "sha256-webLScPFCax18Z2lQHhaWzqqQRvV2Y1lOADqUa7VQbU=", + "owner": "nix-community", + "repo": "fenix", + "rev": "f5a9b01cd81b46228b3737669e8275b1f2da7d35", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1726755586, + "narHash": "sha256-PmUr/2GQGvFTIJ6/Tvsins7Q43KTMvMFhvG6oaYK+Wk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c04d5652cfa9742b1d519688f65d1bbccea9eb7e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "purescript-overlay": { + "inputs": { + "nixpkgs": [ + "dream2nix", + "nixpkgs" + ], + "slimlock": "slimlock" + }, + "locked": { + "lastModified": 1696022621, + "narHash": "sha256-eMjFmsj2G1E0Q5XiibUNgFjTiSz0GxIeSSzzVdoN730=", + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "rev": "047c7933abd6da8aa239904422e22d190ce55ead", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "type": "github" + } + }, + "pyproject-nix": { + "flake": false, + "locked": { + "lastModified": 1702448246, + "narHash": "sha256-hFg5s/hoJFv7tDpiGvEvXP0UfFvFEDgTdyHIjDVHu1I=", + "owner": "davhau", + "repo": "pyproject.nix", + "rev": "5a06a2697b228c04dd2f35659b4b659ca74f7aeb", + "type": "github" + }, + "original": { + "owner": "davhau", + "ref": "dream2nix", + "repo": "pyproject.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "dream2nix": "dream2nix", + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "slimlock": { + "inputs": { + "nixpkgs": [ + "dream2nix", + "purescript-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688610262, + "narHash": "sha256-Wg0ViDotFWGWqKIQzyYCgayeH8s4U1OZcTiWTQYdAp4=", + "owner": "thomashoneyman", + "repo": "slimlock", + "rev": "b5c6cdcaf636ebbebd0a1f32520929394493f1a6", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "slimlock", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..96a559e --- /dev/null +++ b/flake.nix @@ -0,0 +1,146 @@ +{ + description = "Elnafo"; + + nixConfig = { + extra-substituters = [ + "https://cache.elnafo.ru" + "https://bonfire.cachix.org" + ]; + extra-trusted-public-keys = [ + "cache.elnafo.ru:j3VD+Hn+is2Qk3lPXDSdPwHJQSatizk7V82iJ2RP1yo=" + "bonfire.cachix.org-1:mzAGBy/Crdf8NhKail5ciK7ZrGRbPJJobW6TwFb7WYM=" + ]; + }; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + crane = { + url = "github:ipetkov/crane"; + }; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.rust-analyzer-src.follows = ""; + }; + dream2nix = { + url = "github:nix-community/dream2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = {self, ...} @ inputs: let + pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + lib = pkgs.lib; + fenixPkgs = inputs.fenix.packages.x86_64-linux; + craneLib = (inputs.crane.mkLib pkgs).overrideToolchain fenixPkgs.complete.toolchain; + + dreamBuildPackage = { + module, + meta ? {}, + extraModules ? [], + extraArgs ? {}, + }: + ( + inputs.nixpkgs.lib.evalModules { + modules = [module] ++ extraModules; + specialArgs = + { + inherit (inputs) dream2nix; + packageSets.nixpkgs = pkgs; + } + // extraArgs; + } + ) + .config + .public + // {inherit meta;}; + in { + packages.x86_64-linux = rec { + elnafo-radio-frontend = dreamBuildPackage { + module = { + lib, + config, + dream2nix, + ... + }: { + name = "elnafo-radio-frontend"; + version = "0.0.5"; + + imports = [ + dream2nix.modules.dream2nix.WIP-nodejs-builder-v3 + ]; + + mkDerivation = { + src = ./crates/frontend; + }; + + deps = {nixpkgs, ...}: { + inherit + (nixpkgs) + fetchFromGitHub + stdenv + ; + }; + + WIP-nodejs-builder-v3 = { + packageLockFile = "${config.mkDerivation.src}/package-lock.json"; + }; + }; + meta = with lib; { + description = "Materia frontend (nodejs)"; + license = licenses.mit; + broken = false; + }; + }; + elnafo-radio = let + common = { + pname = "elnafo-radio"; + version = "0.1.0"; + + src = pkgs.lib.cleanSourceWith { + src = ./.; + filter = path: type: (craneLib.filterCargoSources path type); + }; + + strictDeps = true; + + #nativeBuildInputs = [pkgs.pkg-config]; + + #buildInputs = [pkgs.openssl]; + }; + + cargoArtifacts = craneLib.buildDepsOnly common; + in + craneLib.buildPackage (common // {inherit cargoArtifacts;}); + + default = elnafo-radio; + }; + + checks.x86_64-linux = { + elnafo-radio-fmt = craneLib.cargoFmt { + src = craneLib.cleanCargoSource (craneLib.path ./.); + }; + }; + + devShells.x86_64-linux = { + default = pkgs.mkShell { + buildInputs = [ + fenixPkgs.complete.toolchain + pkgs.ripgrep + pkgs.postgresql + pkgs.diesel-cli + pkgs.cargo-watch + pkgs.mold-wrapped + pkgs.nodejs + pkgs.cargo-release + ]; + }; + + elnafo-radio = craneLib.devShell { + checks = self.checks.x86_64-linux; + + packages = []; + }; + }; + }; +}