diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 47b2221..a0a48ef 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,31 +1,13 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/alpine { "name": "Alpine", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/base:alpine", - "features": { - "ghcr.io/devcontainers/features/nix:1": {} - }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "nix-env -i nixpkgs-fmt", - - // Configure tool-specific properties. - "runArgs": ["--userns=keep-id"], + "postCreateCommand": "sudo apk add nix nix-dev nix-doc nix-manual nix-bash-completion && sudo chown -R vscode:vscode /nix && echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf", + "runArgs": [ + "--userns=keep-id" + ], "containerUser": "vscode", "customizations": { - // Configure properties specific to VS Code. "vscode": { - // Set *default* container specific settings.json values on container create. - "settings": { - "settings": { - "terminal.integrated.defaultProfile.linux": "dev-shell" - } - }, "extensions": [ "jnoortheen.nix-ide", "ms-azuretools.vscode-docker", @@ -36,7 +18,4 @@ ] } } - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 1e84508..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "terminal.integrated.profiles.linux": { - "dev-shell": { - "path": "bash", - "args": [ "-c", "nix --experimental-features \"nix-command flakes\" develop"], - "overrideName": true - } - } -} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 04d8fab..9276a5d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,13 @@ MIT License -Copyright (c) 2022 stubbfel + Copyright + (c) 2022 + stubbfel -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + Permission + is + hereby + granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/README.md b/README.md index 6af87d0..1d1e817 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,11 @@ ## Nix Flake commands ```sh -# nix flake are experimental and required following options --experimental-features 'nix-command flakes' -# create alias for nix --experimental-features 'nix-command flakes' + # nix flake are experimental and required following options --experimental-features 'nix-command flakes' + # create alias for nix --experimental-features 'nix-command flakes' -alias nixe && echo Alias for nixe exists || alias nixe="nix --experimental-features 'nix-command flakes'" + alias + nixe && echo Alias for nixe exists || alias nixe="nix --experimental-features 'nix-command flakes'" # build nixe build @@ -23,4 +24,4 @@ nixe run .#devTasks.updateFlakeLock # tag project nixe run .#devTasks.autoTag -``` \ No newline at end of file +``` diff --git a/alias.sh b/alias.sh deleted file mode 100644 index 66a3c08..0000000 --- a/alias.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/env sh - -alias nixe='nix --experimental-features "nix-command flakes"' -alias ulock='nixe run .#devTasks.updateFlakeLock' diff --git a/config/default.nix b/config/default.nix index 91065b4..3f01c81 100644 --- a/config/default.nix +++ b/config/default.nix @@ -2,5 +2,5 @@ { nixpkgs = nixpkgs; - playground = { port = "8083"; server = import ../playground/example/services/rust; }; + playground = { port = "8083"; server = import ../playground/example/services/rust; }; } diff --git a/flake.lock b/flake.lock index 6d2c2e6..63feaca 100644 --- a/flake.lock +++ b/flake.lock @@ -1,63 +1,60 @@ { "nodes": { - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1704152458, - "narHash": "sha256-DS+dGw7SKygIWf9w4eNBUZsK+4Ug27NwEWmn2tnbycg=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "88a2cd8166694ba0b6cb374700799cec53aef527", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1704732714, - "narHash": "sha256-ABqK/HggMYA/jMUXgYyqVAcQ8QjeMyr1jcXfTpSHmps=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6723fa4e4f1a30d42a633bef5eb01caeb281adc3", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-23.11", - "type": "indirect" - } - }, - "nixpkgs-lib": { - "locked": { - "dir": "lib", - "lastModified": 1703961334, - "narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9", - "type": "github" - }, - "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" - } - } + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719426051, + "narHash": "sha256-yJL9VYQhaRM7xs0M867ZFxwaONB9T2Q4LnGo1WovuR4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "89c49874fb15f4124bf71ca5f42a04f2ee5825fd", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } }, "root": "root", "version": 7 -} + } diff --git a/flake.nix b/flake.nix index fa6a8c4..c27109b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,62 +1,33 @@ { description = ""; inputs = { - nixpkgs.url = "nixpkgs/nixos-23.11"; - flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "nixpkgs/nixos-24.05"; + flake-utils.url = "github:numtide/flake-utils"; }; - outputs = inputs: - inputs.flake-parts.lib.mkFlake { inherit inputs; } { - systems = [ "x86_64-linux" "aarch64-linux" ]; - perSystem = { config, pkgs, system, ... }: - let - version = "0.0.1"; - name = "develnixos"; + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + version = "0.0.1"; + name = "develnixos"; + space = rec { + config = import ./config { nixpkgs = pkgs; }; + playground = import ./playground/example { config = space.config; }; + }; - updateLockScript = pkgs.writeShellScriptBin "update_flake_lock.sh" '' - nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs - nix --experimental-features 'nix-command flakes' build - ''; + in + { + packages = rec { + playground = space.playground.package; + default = playground; + }; + apps = rec { + playground = flake-utils.lib.mkApp { drv = space.playground.package; exePath = ""; }; + default = playground; + }; - autoTag = pkgs.writeScript "auto_tag.sh" '' - git tag --force v${version} - git push origin v${version} - ''; - - space = rec { - config = import ./config { nixpkgs = pkgs; }; - playground = import ./playground/example { config = space.config; }; - }; - - foo = pkgs.runCommand "linter" '' - echo the_linter - ''; - - in { - packages.default = space.playground.package; - apps = { - default = space.playground.app; - updateFlakeLock = { - type = "app"; - program = "${updateLockScript}/bin/update_flake_lock.sh"; - }; - autoTag = { - type = "app"; - program = "${autoTag}"; - }; - }; - - devShells.default = pkgs.mkShell { - name = "dev-shell"; - packages = [ pkgs.nixfmt ]; - shellHook = '' - . ./alias.sh - ''; - }; - - checks = { - package = space.playground.package; - }; - }; - }; + devShells.default = pkgs.mkShell { + packages = [ pkgs.nixpkgs-fmt pkgs.nixpkgs-lint ]; + }; + }); } diff --git a/playground/example/config/default.nix b/playground/example/config/default.nix index 272e055..8ed8528 100644 --- a/playground/example/config/default.nix +++ b/playground/example/config/default.nix @@ -1,5 +1,5 @@ { config ? import ../../../config { } }: { - playground = { port = "8081"; server = import ../services/python; }; + playground = { port = "8081"; server = import ../services/python; }; } // config diff --git a/playground/example/default.nix b/playground/example/default.nix index 65cc4c2..4f7e67c 100644 --- a/playground/example/default.nix +++ b/playground/example/default.nix @@ -4,7 +4,8 @@ let app = import ./services { config = config; }; -in { +in +{ package = app; diff --git a/playground/example/services/default.nix b/playground/example/services/default.nix index 1df5dda..9abee6e 100644 --- a/playground/example/services/default.nix +++ b/playground/example/services/default.nix @@ -1,5 +1,4 @@ { config ? import ../config { } }: -config.nixpkgs.writeScript "example-web-server" '' - ${config.playground.server {config = config;}} -'' +config.playground.server { config = config; } + diff --git a/playground/example/services/python/default.nix b/playground/example/services/python/default.nix index 6ff8e49..92eace8 100644 --- a/playground/example/services/python/default.nix +++ b/playground/example/services/python/default.nix @@ -2,4 +2,4 @@ config.nixpkgs.writeScript "python-example-web-server" '' ${config.nixpkgs.python3}/bin/python -m http.server ${config.playground.port} -'' \ No newline at end of file +''