Merge pull request #55 from Mr-Andersen/andrey/flake-parts
Use flake-parts
Use flake-parts
"type": "github"
}
},
"flake-compat_5": {
"flake": false,
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1606424373,
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
"lastModified": 1673362319,
"narHash": "sha256-Pjp45Vnj7S/b3BRpZEVfdu8sqqA6nvVjvYu59okhOyI=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "82c16f1682cf50c01cb0280b38a1eed202b3fe9f",
"type": "github"
},
"original": {
"owner": "edolstra",
"ref": "master",
"repo": "flake-compat",
"type": "github"
"id": "flake-parts",
"type": "indirect"
}
},
"flake-compat_6": {
"flake": false,
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"hercules-ci-effects",
"hercules-ci-agent",
"nixpkgs"
]
},
"locked": {
"lastModified": 1606424373,
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
"lastModified": 1666885127,
"narHash": "sha256-uXA/3lhLhwOTBMn9a5zJODKqaRT+SuL5cpEmOz2ULoo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "0e101dbae756d35a376a5e1faea532608e4a4b9a",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"type": "github"
}
},
"flake-utils_5": {
"locked": {
"lastModified": 1667077288,
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"heist": {
"flake": false,
"locked": {
},
"hercules-ci-agent": {
"inputs": {
"flake-compat": "flake-compat_6",
"flake-parts": "flake-parts_2",
"nix-darwin": "nix-darwin",
"nixos-20_09": "nixos-20_09",
"nixos-unstable": "nixos-unstable",
"nixpkgs": "nixpkgs_3",
"pre-commit-hooks-nix": "pre-commit-hooks-nix"
},
"locked": {
"lastModified": 1640356019,
"narHash": "sha256-Aq3QyhXn3P/53bCcyiz3FMYoBaFth5XYHEWMjezXBdc=",
"lastModified": 1673183923,
"narHash": "sha256-vb+AEQJAW4Xn4oHsfsx8H12XQU0aK8VYLtWYJm/ol28=",
"owner": "hercules-ci",
"repo": "hercules-ci-agent",
"rev": "b64596e17047774c9a5b081d733e319ecb4a6f02",
"rev": "b3f8aa8e4a8b22dbbe92cc5a89e6881090b933b3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"ref": "master",
"repo": "hercules-ci-agent",
"type": "github"
"id": "hercules-ci-agent",
"type": "indirect"
}
},
"hercules-ci-effects": {
"inputs": {
"flake-compat": "flake-compat_5",
"flake-parts": "flake-parts",
"hercules-ci-agent": "hercules-ci-agent",
"nixpkgs": "nixpkgs_4",
"nixpkgs-nixops": "nixpkgs-nixops"
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1640168931,
"narHash": "sha256-tNy2sMorQJXkJZFAxFxaTpkFuRXFZNcToT4K0W2K8Gg=",
"lastModified": 1675075737,
"narHash": "sha256-XVrKqj0QDq1vRDdKUniGjtRFHW3uKopzTumSO2FEAN4=",
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"rev": "b0cdd254dbf702b8bfcabd62d350f19fbd86db9f",
"rev": "5f5f6d91fba627b3c0b4f594310c2e5a6b96456c",
"type": "github"
},
"original": {
},
"nix-darwin": {
"inputs": {
"nixpkgs": "nixpkgs_3"
"nixpkgs": [
"hercules-ci-effects",
"hercules-ci-agent",
"nixpkgs"
]
},
"locked": {
"lastModified": 1622060422,
"narHash": "sha256-hPVlvrAyf6zL7tTx0lpK+tMxEfZeMiIZ/A2xaJ41WOY=",
"lastModified": 1667419884,
"narHash": "sha256-oLNw87ZI5NxTMlNQBv1wG2N27CUzo9admaFlnmavpiY=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "007d700e644ac588ad6668e6439950a5b6e2ff64",
"rev": "cfc0125eafadc9569d3d6a16ee928375b77e3100",
"type": "github"
},
"original": {
"type": "github"
}
},
"nixos-20_09": {
"locked": {
"lastModified": 1623585158,
"narHash": "sha256-AjK7M1/six8IBPOI28nm7yC2k8mZIR2F9QrOwFYHAS0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "115dbbe82eb4ec8aabf959068286468a68e0b244",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-20.09",
"repo": "nixpkgs",
"type": "github"
}
},
"nixos-unstable": {
"locked": {
"lastModified": 1630248577,
"narHash": "sha256-9d/yq96TTrnF7qjA6wPYk+rYjWAXwfUmwk3qewezSeg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8d8a28b47b7c41aeb4ad01a2bd8b7d26986c3512",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1647350163,
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
emanote.url = "github:srid/emanote";
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
flake-parts.follows = "hercules-ci-effects/flake-parts";
flake-compat-ci.url = "github:hercules-ci/flake-compat-ci";
emanote.url = "github:srid/emanote";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, flake-compat, flake-compat-ci, hercules-ci-effects, emanote, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
hci-effects = hercules-ci-effects.lib.withPkgs pkgs;
in
{
defaultApp.${system} = self.apps.${system}.live;
defaultPackage.${system} = self.website;
apps."${system}" = {
live = rec {
type = "app";
# '' is required for escaping ${} in nix
script = pkgs.writers.writeBash "emanotePlutonomiconLiveReload.sh" ''
set -xe
export PORT="''${EMANOTE_PORT:-7071}"
${emanote.defaultPackage.${system}}/bin/emanote run --port $PORT
'';
program = builtins.toString script;
};
};
website =
outputs = inputs @ { self, flake-parts, hercules-ci-effects, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ ... }: {
imports = [
hercules-ci-effects.flakeModule
];
systems = [ "x86_64-linux" ];
# { self, hercules-ci-effects, emanote, nixpkgs }
perSystem = { self', inputs', pkgs, system, ... }:
let
configFile = (pkgs.formats.yaml {}).generate "plutonomicon-configFile" {
template.baseUrl = "/plutonomicon/";
};
configDir = pkgs.runCommand "plutonomicon-configDir" {} ''
mkdir -p $out
cp ${configFile} $out/index.yaml
'';
emanote = inputs.emanote.defaultPackage.${system};
in
pkgs.runCommand "plutonomicon-website" {}
''
mkdir $out
${emanote.defaultPackage.${system}}/bin/emanote \
--layers "${self};${configDir}" \
gen $out
'';
effects = { src }: {
gh-pages = hci-effects.runIf (src.ref == "refs/heads/main") (
hci-effects.mkEffect {
src = self;
buildInputs = with pkgs; [ openssh git ];
secretsMap = {
"ssh" = "ssh";
};
effectScript =
let
githubHostKey = "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
in
''
writeSSHKey
echo ${githubHostKey} >> ~/.ssh/known_hosts
{
apps = {
default = self'.apps.live;
live =
let
script = pkgs.writers.writeBash "emanotePlutonomiconLiveReload.sh" ''
set -xe
export PORT="''${EMANOTE_PORT:-7071}"
${emanote}/bin/emanote run --port $PORT
'';
in
{
type = "app";
program = script.outPath;
};
};
export GIT_AUTHOR_NAME="Hercules-CI Effects"
export GIT_COMMITTER_NAME="Hercules-CI Effects"
export EMAIL="[email protected]"
packages = {
default = self'.packages.website;
website =
let
configFile = (pkgs.formats.yaml {}).generate "plutonomicon-configFile" {
template.baseUrl = "/plutonomicon/";
};
configDir = pkgs.runCommand "plutonomicon-configDir" {} ''
mkdir -p $out
cp ${configFile} $out/index.yaml
'';
in
pkgs.runCommand "plutonomicon-website" {}
''
mkdir $out
${emanote}/bin/emanote \
--layers "${self};${configDir}" \
gen $out
'';
};
cp -r --no-preserve=mode ${self.website} ./gh-pages && cd gh-pages
git init -b gh-pages
git remote add origin [email protected]:Plutonomicon/plutonomicon.git
git add .
git commit -m "Deploy to gh-pages"
git push -f origin gh-pages:gh-pages
'';
}
);
};
ciNix = [email protected]{ src }: flake-compat-ci.lib.recurseIntoFlakeWith {
flake = self;
systems = [ "x86_64-linux" ];
effectsArgs = args;
};
};
hercules-ci.github-pages.settings.contents = self'.packages.website;
};
hercules-ci.github-pages.branch = "main";
herculesCI.ciSystems = [ "x86_64-linux" ];
});
}