nix flake

This commit is contained in:
Michael Zhang 2021-08-03 16:57:42 -05:00
parent ca1cdc8179
commit 35f4faecd1
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
8 changed files with 7940 additions and 28 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target
/result
/result-lib

7889
Cargo.nix Normal file

File diff suppressed because it is too large Load diff

3
crate-hashes.json Normal file
View file

@ -0,0 +1,3 @@
{
"typed-html 0.2.2 (git+https://github.com/bodil/typed-html?rev=d95ce1a2930f2385d4f3765d061dbeff3503107f#d95ce1a2930f2385d4f3765d061dbeff3503107f)": "0z1zprngz92yscv07vyqd0kkd8kkpr20fs7ks9c7yg9ygn8ns882"
}

View file

@ -1,12 +1,3 @@
(import
(let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).defaultNix
{ pkgs }:
let workspace = import ./Cargo.nix { inherit pkgs; };
in workspace.rootCrate.build.override { runTests = true; }

View file

@ -3,11 +3,11 @@
"crate2nix": {
"flake": false,
"locked": {
"lastModified": 1627923438,
"narHash": "sha256-/O/FDJynVXOdFhSXQGU2uH/FQF3MS93WMyeY+9fcRaU=",
"lastModified": 1627987096,
"narHash": "sha256-4UZmV651pao101MKoUVh3fHX8OqyoQss5mumOxbrBGk=",
"owner": "kolloch",
"repo": "crate2nix",
"rev": "29460b5c411defa5e8e0851fe7ecbca0f0fa41d3",
"rev": "0ec72d0147d51b26943d622088a13ca273d25469",
"type": "github"
},
"original": {
@ -49,11 +49,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1627978428,
"narHash": "sha256-813SF+K9wEwHVTOhgVpaC3CSZWcjap7Pv3bWppV0U44=",
"lastModified": 1628027051,
"narHash": "sha256-ZbtoEzVT2NV2J2tFmto2PcgdZmsdSyV3rVZBweXkbWk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b3ca5f904aa0f3341413f14e3bd8303a6acd39de",
"rev": "1ab9b0e31da0a6de40867d457b0244c2c895b1dc",
"type": "github"
},
"original": {

View file

@ -25,13 +25,16 @@
})
];
};
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; }) generatedCargoNix;
project = pkgs.callPackage
(generatedCargoNix { inherit name; src = ./.; })
{ defaultCrateOverrides = pkgs.defaultCrateOverrides; };
buildInputs = with pkgs; [];
project = import ./Cargo.nix { inherit pkgs; };
static = pkgs.callPackage ./static.nix {};
in rec {
packages.${name} = project.rootCrate.build;
packages.${name} = pkgs.symlinkJoin {
inherit name;
paths = [
project.rootCrate.build
static
];
};
defaultPackage = packages.${name};
apps.${name} = utils.lib.mkApp {
inherit name;

View file

@ -1,6 +1,3 @@
#![doc = include_str!("../README.md")]
#![recursion_limit = "512"]
#[macro_use]
extern crate serde;
#[macro_use]
@ -18,6 +15,8 @@ mod render;
mod routes;
mod views;
use std::path::PathBuf;
use clap::Clap;
use rocket::fs::{FileServer, relative};
@ -27,6 +26,9 @@ use crate::api::Api;
struct Opt {
#[clap(short = 'v', long = "verbose", parse(from_occurrences))]
verbose: usize,
#[clap(short = 'f', long = "static")]
static_file_path: Option<PathBuf>,
}
#[get("/favicon.ico")]
@ -41,10 +43,15 @@ fn rocket() -> _ {
// .init()
// .unwrap();
let static_file_path = match opt.static_file_path {
Some(path) => path,
None => PathBuf::from(relative!("/static")),
};
use routes::timeline;
let api = Api::new().unwrap();
rocket::build()
.mount("/static", FileServer::from(relative!("/static")))
.mount("/static", FileServer::from(static_file_path))
.mount(
"/",
routes![

17
static.nix Normal file
View file

@ -0,0 +1,17 @@
{ stdenv, sassc }:
stdenv.mkDerivation {
name = "shitter-static";
buildInputs = [ sassc ];
src = ./.;
buildPhase = ''
pwd
ls -l
ls -l sass
${sassc}/bin/sassc -Isass/include sass/index.scss static/css/style.css
'';
installPhase = ''
mkdir -p $out
cp -r static $out
'';
}