generated from stubbfel/nix-project-template
add example
This commit is contained in:
6
config/default.nix
Normal file
6
config/default.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ nixpkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
{
|
||||||
|
nixpkgs = nixpkgs;
|
||||||
|
playground = { port = "8083"; server = import ../playground/example/services/rust; };
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-23.05";
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: rec {
|
|
||||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
||||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
||||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
|
||||||
};
|
|
||||||
}
|
|
||||||
63
flake.lock
generated
63
flake.lock
generated
@@ -1,35 +1,5 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"config": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1,
|
|
||||||
"narHash": "sha256-x1tXOK1tiPQabKK5TOzHQ0HxtFobkEoxwWPvuo6YYvc=",
|
|
||||||
"path": "config",
|
|
||||||
"type": "path"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"path": "config",
|
|
||||||
"type": "path"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"config_2": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1,
|
|
||||||
"narHash": "sha256-x1tXOK1tiPQabKK5TOzHQ0HxtFobkEoxwWPvuo6YYvc=",
|
|
||||||
"path": "config",
|
|
||||||
"type": "path"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"path": "config",
|
|
||||||
"type": "path"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1686331006,
|
"lastModified": 1686331006,
|
||||||
@@ -45,40 +15,9 @@
|
|||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1686331006,
|
|
||||||
"narHash": "sha256-hElRDWUNG655aqF0awu+h5cmDN+I/dQcChRt2tGuGGU=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "85bcb95aa83be667e562e781e9d186c57a07d757",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"ref": "nixos-23.05",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"playground": {
|
|
||||||
"inputs": {
|
|
||||||
"config": "config_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1,
|
|
||||||
"narHash": "sha256-6/SzH0gS563+ouSexLKi3gmTlyOsgg3Ps/plwn8IhnE=",
|
|
||||||
"path": "playground/example/service",
|
|
||||||
"type": "path"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"path": "playground/example/service",
|
|
||||||
"type": "path"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"config": "config",
|
"nixpkgs": "nixpkgs"
|
||||||
"playground": "playground"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
28
flake.nix
28
flake.nix
@@ -1,34 +1,46 @@
|
|||||||
{
|
{
|
||||||
description = "";
|
description = "";
|
||||||
inputs = {
|
inputs = {
|
||||||
config.url = "path:config";
|
nixpkgs.url = "nixpkgs/nixos-23.05";
|
||||||
playground.url = "path:playground/example/service";
|
|
||||||
};
|
};
|
||||||
outputs = { self, config, playground }:
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
let
|
let
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
name = "develnixos";
|
name = "develnixos";
|
||||||
|
|
||||||
forAllSystems = config.forAllSystems;
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
nixpkgsFor = config.nixpkgsFor;
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
|
|
||||||
devTaskScripts = forAllSystems (system: {
|
devTaskScripts = forAllSystems (system: {
|
||||||
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
||||||
git tag --force v${version}
|
git tag --force v${version}
|
||||||
git push origin v${version}
|
git push origin v${version}
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
in rec {
|
|
||||||
packages = playground.packages;
|
|
||||||
|
|
||||||
|
space = forAllSystems (system: rec {
|
||||||
|
config = import ./config { nixpkgs = nixpkgsFor.${system}; };
|
||||||
|
playground = import ./playground/example { config = config; };
|
||||||
|
});
|
||||||
|
|
||||||
|
in rec {
|
||||||
|
packages = forAllSystems (system: {
|
||||||
|
default = space.${system}.playground.package;
|
||||||
|
});
|
||||||
apps = forAllSystems (system:
|
apps = forAllSystems (system:
|
||||||
let
|
let
|
||||||
|
testConfig = import ./config { nixpkgs = nixpkgsFor.${system}; };
|
||||||
|
testapp = import ./playground/example { config = testConfig; };
|
||||||
|
|
||||||
updateLockScript =
|
updateLockScript =
|
||||||
nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
|
nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
|
||||||
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
||||||
nix --experimental-features 'nix-command flakes' build
|
nix --experimental-features 'nix-command flakes' build
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
default = playground.apps.default;
|
default = space.${system}.playground.app;
|
||||||
devTasks = {
|
devTasks = {
|
||||||
updateFlakeLock = {
|
updateFlakeLock = {
|
||||||
type = "app";
|
type = "app";
|
||||||
|
|||||||
5
playground/example/config/default.nix
Normal file
5
playground/example/config/default.nix
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{ config ? import ../../../config { } }:
|
||||||
|
|
||||||
|
{
|
||||||
|
playground = { port = "8081"; server = import ../services/python; };
|
||||||
|
} // config
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
inputs = { config.url = "path:config"; };
|
|
||||||
|
|
||||||
outputs = { self, config }: config //. {playground = { port = "8080"; }; };
|
|
||||||
}
|
|
||||||
16
playground/example/default.nix
Normal file
16
playground/example/default.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ config ? import ../config { } }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
app = import ./services { config = config; };
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
|
package = app;
|
||||||
|
|
||||||
|
app = {
|
||||||
|
type = "app";
|
||||||
|
program = "${app}";
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
description = "";
|
|
||||||
inputs = { config.url = "path:playground/example/config"; };
|
|
||||||
outputs = { self, config }:
|
|
||||||
let
|
|
||||||
version = "0.0.1";
|
|
||||||
name = "develnixos";
|
|
||||||
|
|
||||||
forAllSystems = config.forAllSystems;
|
|
||||||
nixpkgsFor = config.nixpkgsFor;
|
|
||||||
devTaskScripts = forAllSystems (system: {
|
|
||||||
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
|
||||||
git tag --force v${version}
|
|
||||||
git push origin v${version}
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
in rec {
|
|
||||||
packages = forAllSystems (system: {
|
|
||||||
default = nixpkgsFor.${system}.writeScript "python-webserver" ''
|
|
||||||
python -m http.server 8080
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
apps = forAllSystems (system: {
|
|
||||||
default = {
|
|
||||||
type = "app";
|
|
||||||
program = "${packages.${system}.default}";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
5
playground/example/services/default.nix
Normal file
5
playground/example/services/default.nix
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{ config ? import ../config { } }:
|
||||||
|
|
||||||
|
config.nixpkgs.writeScript "example-web-server" ''
|
||||||
|
${config.playground.server {config = config;}}
|
||||||
|
''
|
||||||
5
playground/example/services/python/default.nix
Normal file
5
playground/example/services/python/default.nix
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{ config ? import ../../config { } }:
|
||||||
|
|
||||||
|
config.nixpkgs.writeScript "python-example-web-server" ''
|
||||||
|
${config.nixpkgs.python3}/bin/python -m http.server ${config.playground.port}
|
||||||
|
''
|
||||||
6
playground/example/services/rust/default.nix
Normal file
6
playground/example/services/rust/default.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ config ? import ../../config { } }:
|
||||||
|
|
||||||
|
config.nixpkgs.writeScript "rust-example-web-server" ''
|
||||||
|
${config.nixpkgs.simple-http-server}/bin/simple-http-server --port ${config.playground.port}
|
||||||
|
''
|
||||||
|
|
||||||
Reference in New Issue
Block a user