Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
763910b515 | |||
dca32e4317 | |||
c301978f0b | |||
97fcb5a420 | |||
724c49d056 | |||
7b5d225701 | |||
90fc0ee584 | |||
978321e6ef | |||
7e5adbee24 | |||
803f95cde8 | |||
31fe058879 | |||
421c1a4164 | |||
06fa568225 | |||
520ac2442f | |||
61c4b18bf7 | |||
a3ccfdc4a3 | |||
70ce0f71e2 | |||
ce6150c48b | |||
95b60f3753 | |||
ec9f7a3635 | |||
9fef178a27 | |||
7af58de9fa | |||
6c414bf07d | |||
d39a81720a | |||
9ed5a5b257 | |||
f3c138b7d4 | |||
51b8519fc2 | |||
b1bce024de | |||
89a5e52857 | |||
da9f9263d1 | |||
62accd6e43 | |||
210a1f4592 | |||
3708768f34 | |||
94265ba39f | |||
7e3ca9c620 | |||
a3c978e0fc | |||
67db10460f | |||
615f71bfd7 |
20
.github/workflows/nix-build.yml
vendored
Normal file
20
.github/workflows/nix-build.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name: "Nix Build"
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v8
|
||||
- name: Cache nix store
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: /nix
|
||||
key: ${{ runner.os }}-nix-store
|
||||
- uses: cachix/cachix-action@v5
|
||||
with:
|
||||
name: hitsofcode
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
attributes: package
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
repos
|
||||
cache
|
||||
hoc.log
|
||||
result
|
||||
|
51
Cargo.lock
generated
51
Cargo.lock
generated
@ -281,12 +281,6 @@ dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "antidote"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.26"
|
||||
@ -784,9 +778,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.11.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77519ef7c5beee314d0804d4534f01e0f9e8d9acdee2b7a48627e590b27e0ec4"
|
||||
checksum = "b7da16ceafe24cedd9ba02c4463a2b506b6493baf4317c79c5acb553134a3c15"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
@ -836,7 +830,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoc"
|
||||
version = "0.11.5"
|
||||
version = "0.11.7"
|
||||
dependencies = [
|
||||
"actix-rt",
|
||||
"actix-web",
|
||||
@ -1058,9 +1052,9 @@ checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.10.0"
|
||||
version = "0.12.0+0.99.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9ec6bca50549d34a392611dde775123086acbd994e3fff64954777ce2dc2e51"
|
||||
checksum = "05dff41ac39e7b653f5f1550886cf00ba52f8e7f57210b633cdeedb3de5b236c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@ -1129,11 +1123,10 @@ checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7"
|
||||
|
||||
[[package]]
|
||||
name = "log4rs"
|
||||
version = "0.10.0"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "853db99624c59798ddcf027dbe486541dd5cb5008ac6a6aaf217cc6fa044ee71"
|
||||
checksum = "b47ba5437ccdf01e4addd4d2347ef561911d57f908f4db1e1b192d5c25a92715"
|
||||
dependencies = [
|
||||
"antidote",
|
||||
"arc-swap",
|
||||
"chrono",
|
||||
"flate2",
|
||||
@ -1142,6 +1135,7 @@ dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"log-mdc",
|
||||
"parking_lot",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_derive",
|
||||
@ -1615,9 +1609,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.10.1"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0e798e19e258bf6c30a304622e3e9ac820e483b06a1857a026e1f109b113fe4"
|
||||
checksum = "a9f62f24514117d09a8fc74b803d3d65faa27cea1c7378fb12b0d002913f3831"
|
||||
dependencies = [
|
||||
"base64 0.11.0",
|
||||
"bytes",
|
||||
@ -1774,9 +1768,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.104"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
|
||||
checksum = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
@ -1793,9 +1787,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.104"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
|
||||
checksum = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1804,9 +1798,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.47"
|
||||
version = "1.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15913895b61e0be854afd32fd4163fcd2a3df34142cf2cb961b310ce694cbf90"
|
||||
checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@ -1915,9 +1909,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "structopt"
|
||||
version = "0.3.9"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1bcbed7d48956fcbb5d80c6b95aedb553513de0a1b451ea92679d999c010e98"
|
||||
checksum = "c8faa2719539bbe9d77869bfb15d4ee769f99525e707931452c97b693b3f159d"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"lazy_static",
|
||||
@ -1926,9 +1920,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "structopt-derive"
|
||||
version = "0.4.2"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "095064aa1f5b94d14e635d0a5684cf140c43ae40a0fd990708d38f5d669e5f64"
|
||||
checksum = "3f88b8e18c69496aad6f9ddf4630dd7d585bcaf765786cb415b9aec2fe5a0430"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
@ -2233,13 +2227,12 @@ checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
|
||||
[[package]]
|
||||
name = "vergen"
|
||||
version = "3.0.4"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6aba5e34f93dc7051dfad05b98a18e9156f27e7b431fe1d2398cb6061c0a1dba"
|
||||
checksum = "4ce50d8996df1f85af15f2cd8d33daae6e479575123ef4314a51a70a230739cb"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"chrono",
|
||||
"failure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
16
Cargo.toml
16
Cargo.toml
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.11.5"
|
||||
version = "0.11.7"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
@ -10,19 +10,19 @@ actix-web = "2.0.0"
|
||||
badge = "0.2.0"
|
||||
bytes = "0.5.4"
|
||||
futures = "0.3.1"
|
||||
git2 = "0.11.0"
|
||||
git2 = "0.13.0"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.8"
|
||||
log4rs = "0.10.0"
|
||||
log4rs = "0.11.0"
|
||||
number_prefix = "0.3.0"
|
||||
openssl-probe = "0.1.2"
|
||||
reqwest = "0.10.1"
|
||||
serde = "1.0.104"
|
||||
reqwest = "0.10.3"
|
||||
serde = "1.0.105"
|
||||
serde_derive = "1.0.103"
|
||||
serde_json = "1.0.47"
|
||||
structopt = "0.3.9"
|
||||
serde_json = "1.0.48"
|
||||
structopt = "0.3.12"
|
||||
actix-rt = "1.0.0"
|
||||
|
||||
[build-dependencies]
|
||||
ructe = "0.9.2"
|
||||
vergen = "3.0.4"
|
||||
vergen = "3.1.0"
|
||||
|
@ -45,6 +45,10 @@ $ docker build .
|
||||
|
||||
inside the repository.
|
||||
|
||||
I'm currently working on migrating to [nix](https://nixos.org/nix). To get a
|
||||
development shell, run `nix-shell`, to build the package run `nix-build --attr
|
||||
package` and to build the Docker image, run `nix-build --attr dockerImage`.
|
||||
|
||||
|
||||
## Running
|
||||
|
||||
|
1
crate-hashes.json
Normal file
1
crate-hashes.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
51
default.nix
Normal file
51
default.nix
Normal file
@ -0,0 +1,51 @@
|
||||
{ sources ? import ./nix/sources.nix
|
||||
, system ? builtins.currentSystem
|
||||
}:
|
||||
|
||||
let
|
||||
rustOverlay = import "${sources.nixpkgs-mozilla}/rust-overlay.nix";
|
||||
cargo2nixOverlay = import "${sources.cargo2nix}/overlay";
|
||||
|
||||
pkgs = import sources.nixpkgs {
|
||||
# pkgs = import <nixpkgs> {
|
||||
inherit system;
|
||||
overlays = [ cargo2nixOverlay rustOverlay ];
|
||||
};
|
||||
|
||||
rustPkgs = pkgs.rustBuilder.makePackageSet' {
|
||||
rustChannel = "stable";
|
||||
packageFun = import ./Cargo.nix;
|
||||
localPatterns =
|
||||
[
|
||||
''^(src|tests)(/.*)?''
|
||||
''[^/]*\.(rs|toml)$''
|
||||
# include other directory from the project repository
|
||||
''^templates(/.*)?''
|
||||
''^static(/.*)?''
|
||||
''^.git.*(/.*)?''
|
||||
];
|
||||
# packageOverrides
|
||||
};
|
||||
in
|
||||
rec {
|
||||
inherit rustPkgs;
|
||||
shell = pkgs.mkShell {
|
||||
inputsFrom = pkgs.lib.mapAttrsToList (_: pkg: pkg { }) rustPkgs.noBuild.workspace;
|
||||
nativeBuildInputs = with rustPkgs; [ cargo rustc ];
|
||||
};
|
||||
package = (rustPkgs.workspace.hoc {}).overrideAttrs (drv: {
|
||||
buildInputs = drv.buildInputs or [ ] ++ [ pkgs.git ];
|
||||
});
|
||||
dockerImage =
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "vbrandl/hits-of-code";
|
||||
tag = package.version;
|
||||
|
||||
contents = [ package ];
|
||||
|
||||
config = {
|
||||
Cmd = [ "/bin/hoc" ];
|
||||
WorkingDir = "/home/hoc";
|
||||
};
|
||||
};
|
||||
}
|
50
nix/sources.json
Normal file
50
nix/sources.json
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"cargo2nix": {
|
||||
"branch": "master",
|
||||
"description": "Convert a Cargo.lock to mkRustCrate statements for import in Nix",
|
||||
"homepage": "",
|
||||
"owner": "tenx-tech",
|
||||
"repo": "cargo2nix",
|
||||
"rev": "7bc062ccffc41dc7d3759b8b797e8b4f8dd23a15",
|
||||
"sha256": "1z7xwk1hbp26aydsk3y07riy0ivwqss06n1470mvdl7allfcd1w5",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/tenx-tech/cargo2nix/archive/7bc062ccffc41dc7d3759b8b797e8b4f8dd23a15.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"niv": {
|
||||
"branch": "master",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "98c74a80934123cb4c3bf3314567f67311eb711a",
|
||||
"sha256": "1w8n54hapd4x9f1am33icvngkqns7m3hl9yair38yqq08ffwg0kn",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/98c74a80934123cb4c3bf3314567f67311eb711a.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "nixpkgs-unstable",
|
||||
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs-channels",
|
||||
"rev": "053ad4e0db7241ae6a02394d62750fdc5d64aa9f",
|
||||
"sha256": "11l9sr8zg8j1n5p43zjkqwpj59gn8c84z1kf16icnsbnv2smzqdc",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/053ad4e0db7241ae6a02394d62750fdc5d64aa9f.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-mozilla": {
|
||||
"branch": "master",
|
||||
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",
|
||||
"homepage": null,
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
|
||||
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed483e980dfb4666ae0ed17845c4220e5e7c.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
134
nix/sources.nix
Normal file
134
nix/sources.nix
Normal file
@ -0,0 +1,134 @@
|
||||
# This file has been generated by Niv.
|
||||
|
||||
let
|
||||
|
||||
#
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
|
||||
fetch_tarball = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
||||
|
||||
fetch_builtin-tarball = spec:
|
||||
builtins.trace
|
||||
''
|
||||
WARNING:
|
||||
The niv type "builtin-tarball" will soon be deprecated. You should
|
||||
instead use `builtin = true`.
|
||||
|
||||
$ niv modify <package> -a type=tarball -a builtin=true
|
||||
''
|
||||
builtins_fetchTarball { inherit (spec) url sha256; };
|
||||
|
||||
fetch_builtin-url = spec:
|
||||
builtins.trace
|
||||
''
|
||||
WARNING:
|
||||
The niv type "builtin-url" will soon be deprecated. You should
|
||||
instead use `builtin = true`.
|
||||
|
||||
$ niv modify <package> -a type=file -a builtin=true
|
||||
''
|
||||
(builtins_fetchurl { inherit (spec) url sha256; });
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs spec
|
||||
else if spec.type == "git" then fetch_git spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url spec
|
||||
else
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = fetch config.pkgs name spec; }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig =
|
||||
{ sourcesFile ? ./sources.json
|
||||
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
16
src/error.rs
16
src/error.rs
@ -43,13 +43,17 @@ impl ResponseError for Error {
|
||||
let mut buf = Vec::new();
|
||||
match self {
|
||||
Error::GitNoMaster => {
|
||||
templates::p404_no_master(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap();
|
||||
HttpResponse::NotFound()
|
||||
.content_type("text/html")
|
||||
.body(buf)
|
||||
},
|
||||
templates::p404_no_master(
|
||||
&mut buf,
|
||||
VERSION_INFO,
|
||||
REPO_COUNT.load(Ordering::Relaxed),
|
||||
)
|
||||
.unwrap();
|
||||
HttpResponse::NotFound().content_type("text/html").body(buf)
|
||||
}
|
||||
_ => {
|
||||
templates::p500(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap();
|
||||
templates::p500(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed))
|
||||
.unwrap();
|
||||
HttpResponse::InternalServerError()
|
||||
.content_type("text/html")
|
||||
.body(buf)
|
||||
|
80
vm.nix
Normal file
80
vm.nix
Normal file
@ -0,0 +1,80 @@
|
||||
# Nix configuration for a VM to run a custom configured Vim
|
||||
#
|
||||
# It is intended as an example of building a VM that builds Vim for testing
|
||||
# and evaluation purposes. It does not represent a production or secure
|
||||
# deployment.
|
||||
|
||||
{ sources ? import ./nix/sources.nix
|
||||
, pkgs ? import sources.nixpkgs { }
|
||||
, callPackage ? pkgs.callPackage
|
||||
, config
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
# config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
hoc = pkgs.callPackage ./default.nix { };
|
||||
|
||||
# hoc = cargoNix.rootCrate.build;
|
||||
in
|
||||
{
|
||||
environment = {
|
||||
systemPackages = with pkgs; [
|
||||
(
|
||||
hoc
|
||||
# import ./default.nix
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
networking.hostName = "hoc"; # Define your hostname.
|
||||
|
||||
system.stateVersion = "19.09"; # The version of NixOS originally installed
|
||||
|
||||
# Set security options:
|
||||
security = {
|
||||
sudo = {
|
||||
enable = true; # Enable sudo
|
||||
wheelNeedsPassword = false; # Allow wheel members to run sudo without a passowrd
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
|
||||
# List services that you want to enable:
|
||||
services.openssh = {
|
||||
enable = true; # Enable the OpenSSH daemon.
|
||||
#permitRootLogin = "yes"; # Probably want to change this in production
|
||||
#challengeResponseAuthentication = true; # Probably want to change this in production
|
||||
#passwordAuthentication = true; # Probably want to change this in production
|
||||
openFirewall = true;
|
||||
hostKeys = [
|
||||
{
|
||||
path = "/etc/ssh/ssh_host_ed25519_key"; # Generate a key for the vm
|
||||
type = "ed25519"; # Use the current best key type
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Users of the Vim VM:
|
||||
users.mutableUsers = false; # Remove any users not defined in here
|
||||
|
||||
users.users.root = {
|
||||
password = "123456"; # Probably want to change this in production
|
||||
};
|
||||
|
||||
# Misc groups:
|
||||
users.groups.nixos.gid = 1000;
|
||||
|
||||
# NixOS users
|
||||
users.users.nixos = {
|
||||
isNormalUser = true;
|
||||
uid = 1000;
|
||||
group = "nixos";
|
||||
extraGroups = [ "wheel" ];
|
||||
password = "123456"; # Probably want to change this in production
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user