This repository has been archived by the owner on May 5, 2023. It is now read-only.
Initial version of the faucet #1
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let pkgs = import ./nix {}; in pkgs.packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const axios = require("axios"); | ||
|
||
async function getAccountStatus(hostUrl, accountId) { | ||
const response = await axios.get(`${hostUrl}/account/${accountId}`); | ||
return response.data; | ||
} | ||
|
||
async function getNodeSettings(hostUrl) { | ||
const response = await axios.get(`${hostUrl}/settings`); | ||
return response.data; | ||
} | ||
|
||
async function postMsg(hostUrl, msg) { | ||
axios.post(`${hostUrl}/message`, msg, { | ||
headers: { | ||
"content-type": "application/octet-stream" | ||
} | ||
}); | ||
} | ||
|
||
module.exports = { | ||
getAccountStatus, | ||
getNodeSettings, | ||
postMsg | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ sources ? import ./sources.nix }: | ||
with { | ||
mozilla-overlay = import sources.nixpkgs-mozilla; | ||
|
||
overlay = self: super: { | ||
inherit (import sources.niv { }) niv; | ||
nodejs = super.nodejs-slim-11_x; | ||
inherit (import sources.yarn2nix { pkgs = self; }) mkYarnPackage yarn2nix; | ||
packages = self.callPackages ./packages.nix { }; | ||
iohkNix = import sources.iohk-nix { | ||
application = "jormungandr-faucet"; | ||
nixpkgsOverride = self; | ||
}; | ||
|
||
rustc = super.latest.rustChannels.stable.rust.override { | ||
targets = [ "wasm32-unknown-unknown" ]; | ||
}; | ||
}; | ||
}; | ||
import sources.nixpkgs { | ||
overlays = [ mozilla-overlay overlay ]; | ||
config = { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
imports = import ./module-list.nix; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
jormungandr-faucet = (import ../. { }).packages.jormungandr-faucet; | ||
cfg = config.services.jormungandr-faucet; | ||
inherit (lib) mkOption types; | ||
in { | ||
options.services.jormungandr-faucet = { | ||
package = mkOption { | ||
type = types.package; | ||
default = (import ../. {}).packages.jormungandr-faucet-js; | ||
defaultText = "jormungandr-faucet"; | ||
description = '' | ||
The jormungandr-faucet package to be used | ||
''; | ||
}; | ||
|
||
jormungandrApi = mkOption { | ||
type = types.str; | ||
default = "http://localhost:8443/api/v0"; | ||
}; | ||
|
||
secretKeyPath = mkOption { | ||
type = types.str; | ||
default = "/var/lib/private/jormungandr-faucet/private.key"; | ||
}; | ||
|
||
port = mkOption { | ||
type = types.port; | ||
default = 3008; | ||
}; | ||
|
||
lovelacesToGive = mkOption { | ||
type = types.int; | ||
default = 1; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
cfg = config.services.jormungandr-faucet; | ||
inherit (lib) mkOption types mkIf; | ||
in { | ||
options.services.jormungandr-faucet.enable = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = '' | ||
Enable the Jormungandr Faucet, an HTTP service that talks to Jormungandr | ||
to spread ADA love. | ||
''; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.jormungandr-faucet = { | ||
description = "jormungandr-faucet daemon"; | ||
after = [ "jormungandr.service"]; | ||
wantedBy = [ "multi-user.target" ]; | ||
|
||
serviceConfig = { | ||
DynamicUser = true; | ||
Restart = "always"; | ||
User = "jormungandr-faucet"; | ||
RestartSec = "10s"; | ||
StartLimitBurst = 50; | ||
StateDirectory = "jormungandr-faucet"; | ||
}; | ||
|
||
environment = { | ||
JORMUNGANDR_API = cfg.jormungandrApi; | ||
PORT = toString cfg.port; | ||
LOVELACES_TO_GIVE = toString cfg.lovelacesToGive; | ||
}; | ||
|
||
serviceConfig.PermissionsStartOnly = true; | ||
preStart = '' | ||
ls -la /var/lib | ||
cp /var/lib/keys/jormungandr-faucet.key /var/lib/private/jormungandr-faucet/private.key | ||
''; | ||
|
||
script = '' | ||
export SECRET_KEY="$(< /var/lib/private/jormungandr-faucet/private.key)" | ||
${cfg.package}/bin/faucet | ||
''; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
./jormungandr-faucet-options.nix | ||
./jormungandr-faucet-service.nix | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ pkgs, supportedSystems ? [ "x86_64-linux" ] }: | ||
|
||
let | ||
inherit (pkgs) lib; | ||
inherit (lib) genAttrs hydraJob; | ||
|
||
forAllSystems = genAttrs supportedSystems; | ||
|
||
importTest = fn: args: system: | ||
let | ||
imported = import fn; | ||
test = import (pkgs.path + "/nixos/tests/make-test.nix") imported; | ||
in test ({ inherit system; } // args); | ||
|
||
callTest = fn: args: | ||
forAllSystems (system: hydraJob (importTest fn args system)); | ||
in rec { | ||
simple = callTest ./simple.nix { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ pkgs , ... }: | ||
|
||
{ | ||
name = "jormungandr-faucet-test"; | ||
nodes = { | ||
machine = { config, pkgs, ... }: { | ||
imports = [ | ||
../. | ||
]; | ||
services = { | ||
jormungandr-faucet = { | ||
enable = true; | ||
}; | ||
|
||
jormungandr = { | ||
enable = true; | ||
}; | ||
}; | ||
}; | ||
}; | ||
testScript = '' | ||
startAll | ||
$machine->execute("mkdir -p /var/lib/keys"); | ||
$machine->execute("echo SECRET_KEY=key > /var/lib/keys/jormungandr-faucet.key"); | ||
$machine->waitForUnit("jormungandr-faucet.service"); | ||
$machine->waitForOpenPort(3008); | ||
''; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ stdenv, mkYarnPackage, yarn2nix, callPackage }: | ||
|
||
{ | ||
jormungandr-faucet-js = mkYarnPackage { | ||
name = "jormungandr-faucet"; | ||
src = ../.; | ||
packageJSON = ../package.json; | ||
yarnLock = ../yarn.lock; | ||
}; | ||
|
||
jormungandr-faucet-tests = callPackage ./nixos/tests {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"gitignore": { | ||
"branch": "master", | ||
"description": "Nix function for filtering local git sources", | ||
"homepage": "", | ||
"owner": "hercules-ci", | ||
"repo": "gitignore", | ||
"rev": "31860d428b0d6cc03fb7ca9eca8b99dc3750ee5e", | ||
"sha256": "1km1nryf41f0xc7n632vqc8p7wgx5lz7nmz3qm5zj1dr6260jk3m", | ||
"type": "tarball", | ||
"url": "https://github.com/hercules-ci/gitignore/archive/31860d428b0d6cc03fb7ca9eca8b99dc3750ee5e.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
}, | ||
"iohk-nix": { | ||
"branch": "jormungandr-master", | ||
"description": "nix scripts shared across projects", | ||
"homepage": null, | ||
"owner": "input-output-hk", | ||
"repo": "iohk-nix", | ||
"rev": "689cf245da41f5178246802d3318ca610529ed56", | ||
"sha256": "0fn3p94iblgi366vr6773h8i6i7b7p1gjcsb7005rsf6z2h71khb", | ||
"type": "tarball", | ||
"url": "https://github.com/input-output-hk/iohk-nix/archive/689cf245da41f5178246802d3318ca610529ed56.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": "c57098815e542b3a345d6f3fa821ea87c75b751d", | ||
"sha256": "0q4xjg2nkzcvh62m92d1d2xzxf6xhfr512yndaklqp6qy8vz29jx", | ||
"type": "tarball", | ||
"url": "https://github.com/nmattia/niv/archive/c57098815e542b3a345d6f3fa821ea87c75b751d.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": "e19054ab3cd5b7cc9a01d0efc71c8fe310541065", | ||
"sha256": "0b92yhkj3pq58svyrx7jp0njhaykwr29079izqn6qs638v8zvhl2", | ||
"type": "tarball", | ||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/e19054ab3cd5b7cc9a01d0efc71c8fe310541065.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": "b52a8b7de89b1fac49302cbaffd4caed4551515f", | ||
"sha256": "1np4fmcrg6kwlmairyacvhprqixrk7x9h89k813safnlgbgqwrqb", | ||
"type": "tarball", | ||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/b52a8b7de89b1fac49302cbaffd4caed4551515f.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
}, | ||
"yarn2nix": { | ||
"branch": "master", | ||
"description": "Generate nix expressions from a yarn.lock file", | ||
"homepage": null, | ||
"owner": "moretea", | ||
"repo": "yarn2nix", | ||
"rev": "7effadded30d611a460e212cb73614506ef61c52", | ||
"sha256": "0r4ww3mjx3n7bn2v1iav33liyphyr2x005ak6644qs15bp4bn3cr", | ||
"type": "tarball", | ||
"url": "https://github.com/moretea/yarn2nix/archive/7effadded30d611a460e212cb73614506ef61c52.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add iohk-nix (see iohk-ops for how). We can put genesis files/hashes and any other env specific data in there that we can use to key off of. Granted, we're using iohk-ops here so it's not 100% needed but could be useful for end users wanting to run a faucet without iohk-ops. See cardanoLib in there. We'd want to add a jormungandr_testnet attribute with env specific stuff in there.