diff --git a/config/default.nix b/config/default.nix new file mode 100644 index 0000000..91065b4 --- /dev/null +++ b/config/default.nix @@ -0,0 +1,6 @@ +{ nixpkgs ? import { } }: + +{ + nixpkgs = nixpkgs; + playground = { port = "8083"; server = import ../playground/example/services/rust; }; +} diff --git a/config/flake.nix b/config/flake.nix deleted file mode 100644 index c65a53c..0000000 --- a/config/flake.nix +++ /dev/null @@ -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; }); - }; -} diff --git a/flake.lock b/flake.lock index b00729f..7fa99d6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,35 +1,5 @@ { "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": { "locked": { "lastModified": 1686331006, @@ -45,40 +15,9 @@ "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": { "inputs": { - "config": "config", - "playground": "playground" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index b07d11f..b96f7af 100644 --- a/flake.nix +++ b/flake.nix @@ -1,34 +1,46 @@ { description = ""; inputs = { - config.url = "path:config"; - playground.url = "path:playground/example/service"; + nixpkgs.url = "nixpkgs/nixos-23.05"; }; - outputs = { self, config, playground }: + + outputs = { self, nixpkgs }: let version = "0.0.1"; name = "develnixos"; - forAllSystems = config.forAllSystems; - nixpkgsFor = config.nixpkgsFor; + supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + devTaskScripts = forAllSystems (system: { autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" '' git tag --force 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: let + testConfig = import ./config { nixpkgs = nixpkgsFor.${system}; }; + testapp = import ./playground/example { config = testConfig; }; + updateLockScript = nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" '' nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs nix --experimental-features 'nix-command flakes' build ''; in { - default = playground.apps.default; + default = space.${system}.playground.app; devTasks = { updateFlakeLock = { type = "app"; diff --git a/playground/example/config/default.nix b/playground/example/config/default.nix new file mode 100644 index 0000000..272e055 --- /dev/null +++ b/playground/example/config/default.nix @@ -0,0 +1,5 @@ +{ config ? import ../../../config { } }: + +{ + playground = { port = "8081"; server = import ../services/python; }; +} // config diff --git a/playground/example/config/flake.nix b/playground/example/config/flake.nix deleted file mode 100644 index e3b5ae4..0000000 --- a/playground/example/config/flake.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - inputs = { config.url = "path:config"; }; - - outputs = { self, config }: config //. {playground = { port = "8080"; }; }; -} diff --git a/playground/example/default.nix b/playground/example/default.nix new file mode 100644 index 0000000..65cc4c2 --- /dev/null +++ b/playground/example/default.nix @@ -0,0 +1,16 @@ +{ config ? import ../config { } }: + +let + + app = import ./services { config = config; }; + +in { + + package = app; + + app = { + type = "app"; + program = "${app}"; + }; + +} diff --git a/playground/example/service/flake.nix b/playground/example/service/flake.nix deleted file mode 100644 index 1919ca6..0000000 --- a/playground/example/service/flake.nix +++ /dev/null @@ -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}"; - }; - }); - }; -} diff --git a/playground/example/services/default.nix b/playground/example/services/default.nix new file mode 100644 index 0000000..1df5dda --- /dev/null +++ b/playground/example/services/default.nix @@ -0,0 +1,5 @@ +{ config ? import ../config { } }: + +config.nixpkgs.writeScript "example-web-server" '' + ${config.playground.server {config = config;}} +'' diff --git a/playground/example/services/python/default.nix b/playground/example/services/python/default.nix new file mode 100644 index 0000000..6ff8e49 --- /dev/null +++ b/playground/example/services/python/default.nix @@ -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} +'' \ No newline at end of file diff --git a/playground/example/services/rust/default.nix b/playground/example/services/rust/default.nix new file mode 100644 index 0000000..ddb38c8 --- /dev/null +++ b/playground/example/services/rust/default.nix @@ -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} +'' +