diff --git a/tortoise/.direnv/flake-profile b/tortoise/.direnv/flake-profile index 0c05709..f9f4da1 120000 --- a/tortoise/.direnv/flake-profile +++ b/tortoise/.direnv/flake-profile @@ -1 +1 @@ -flake-profile-1-link \ No newline at end of file +flake-profile-18-link \ No newline at end of file diff --git a/tortoise/.direnv/flake-profile-1-link b/tortoise/.direnv/flake-profile-1-link deleted file mode 120000 index e583a7d..0000000 --- a/tortoise/.direnv/flake-profile-1-link +++ /dev/null @@ -1 +0,0 @@ -/nix/store/ml5jibqk9rhd8gfps532ry58njp2j5sd-nix-shell-env \ No newline at end of file diff --git a/tortoise/.direnv/flake-profile-18-link b/tortoise/.direnv/flake-profile-18-link new file mode 120000 index 0000000..60c8dcd --- /dev/null +++ b/tortoise/.direnv/flake-profile-18-link @@ -0,0 +1 @@ +/nix/store/d9kjbddwp2dsiwpvdvmaff9lpgy5rhsv-nix-shell-env \ No newline at end of file diff --git a/tortoise/flake.nix b/tortoise/flake.nix index 8f38de5..623929f 100644 --- a/tortoise/flake.nix +++ b/tortoise/flake.nix @@ -1,23 +1,37 @@ { - description = "A Nix-flake-based Guile development environment"; + description = "A Nix-flake-based C/C++ development environment"; + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; outputs = { self, nixpkgs }: let - supportedSystems = - [ "x86_64-linux" ]; - forEachSupportedSystem = f: - nixpkgs.lib.genAttrs supportedSystems - (system: f { pkgs = import nixpkgs { inherit system; }; }); - in { + supportedSystems = [ "x86_64-linux" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in + { devShells = forEachSupportedSystem ({ pkgs }: { - default = pkgs.mkShell { - packages = with pkgs; [ - gnuplot - guile - gcc - ]; - }; + default = pkgs.mkShell.override + { + # Override stdenv in order to change compiler: + stdenv = pkgs.clangStdenv; + } + { + packages = with pkgs; [ + clang-tools + cmake + codespell + conan + cppcheck + doxygen + gtest + lcov + vcpkg + vcpkg-tool + ] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]); + }; }); }; } + diff --git a/tortoise/tortoise b/tortoise/tortoise deleted file mode 100755 index 1358568..0000000 Binary files a/tortoise/tortoise and /dev/null differ diff --git a/tortoise/tortoise.c b/tortoise/tortoise.c index 985a762..30e6f55 100644 --- a/tortoise/tortoise.c +++ b/tortoise/tortoise.c @@ -24,7 +24,7 @@ start_gnuplot() { if (!pid) { dup2 (pipes[0], STDIN_FILENO); execlp ("gnuplot", NULL); - return; /* Not reached. */ + return 0; /* Not reached. */ } output = fdopen(pipes[1], "w"); @@ -51,14 +51,6 @@ static void tortoise_reset () { fprintf(global_output, "clear\n"); fflush(global_output); } - - -int main(int argc, char *argv[]) { - global_output = start_gnuplot(); - tortoise_reset (); - return EXIT_SUCCESS; -} - static void draw_line(FILE *output, double x1, double y1, double x2, double y2) { fprintf(output, "plot [0:1] %f + %f * t, %f + %f * t notitle\n", @@ -74,6 +66,11 @@ static void tortoise_penup() { pendown = 0; } +static void tortoise_turn (double degrees) +{ + direction += M_PI / 180.0 * degrees; +} + static void tortoise_move(double length) { double newX, newY; @@ -86,3 +83,17 @@ static void tortoise_move(double length) { x = newX; y = newY; } + + +int main(int argc, char *argv[]) { + global_output = start_gnuplot(); + tortoise_reset (); + int i; + tortoise_pendown(); + for (i = 1; i <= 4; ++i) { + tortoise_move(3.0); + tortoise_turn(90.0); + }; + return EXIT_SUCCESS; +} +