commit 5fcd66df541b4d8e26fe39275a767b1322703b3d Author: stubbfel Date: Sat May 27 17:57:52 2023 +0200 Initial commit diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..83a1938 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// 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-3.17", + "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. + "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", + "eamodio.gitlens", + "streetsidesoftware.code-spell-checker", + "timonwong.shellcheck", + "foxundermoon.shell-format" + ] + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2f5dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1e84508 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "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/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..825c32f --- /dev/null +++ b/CHANGELOG @@ -0,0 +1 @@ +# Changelog diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..04d8fab --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6af87d0 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# develnixos.new + +## 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' + +alias nixe && echo Alias for nixe exists || alias nixe="nix --experimental-features 'nix-command flakes'" + +# build +nixe build + +# run +nixe run + +# open development shell +nixe develop + +# update flake.lock +nixe run .#devTasks.updateFlakeLock + +# tag project +nixe run .#devTasks.autoTag + +``` \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bcb4a4e --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1668595291, + "narHash": "sha256-j8cyfbtT5sAYPYwbERgTDzfD48ZernL0/V668eGpXAM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6474d93e007e4d165bcf48e7f87de2175c93d10b", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.05-small", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3b7dc80 --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + description = ""; + inputs.nixpkgs.url = "nixpkgs/nixos-22.05-small"; + + outputs = { self, nixpkgs }: + let + name = "develnixos.new"; + version = "0.0.1"; + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + 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 = forAllSystems (system: + { + default = nixpkgsFor.${system}.stdenv.mkDerivation { + name = name; + src = self; + buildPhase = "echo nothing todo"; + installPhase = "mkdir -p $out/bin; install -t $out/bin src/hello.sh"; + }; + }); + + apps = forAllSystems (system: + let + 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 = { type = "app"; program = "${packages.${system}.default}/bin/hello.sh"; }; + devTasks = { + updateFlakeLock = { type = "app"; program = "${updateLockScript}/bin/update_flake_lock.sh"; }; + autoTag = { type = "app"; program = "${devTaskScripts.${system}.autoTag}"; }; + }; + }); + + devShells = forAllSystems (system: + { + default = nixpkgsFor.${system}.mkShell { + name = "dev-shell"; + packages = [ ]; + shellHook = '' + alias nixe="nix --experimental-features 'nix-command flakes'" + ''; + }; + }); + + hydraJobs = { + tarball = nixpkgsFor.x86_64-linux.releaseTools.sourceTarball { + name = name; + src = self; + version = version; + officialRelease = true; + bootstrapBuildInputs = [ ]; + distPhase = '' + mkdir $out/tarballs + tar -czvf $out/tarballs/${name}-${version}.tar.gz * + ''; + }; + + runCommandHook = { + recurseForDerivations = { }; + autoTag = devTaskScripts.x86_64-linux.autoTag; + }; + }; + }; +} diff --git a/src/hello.sh b/src/hello.sh new file mode 100755 index 0000000..2202fe7 --- /dev/null +++ b/src/hello.sh @@ -0,0 +1,3 @@ +#!/bin/env bash + +echo "hello world" \ No newline at end of file